Css 使div可滚动并显示伪元素
我有一个很长的货币div,我想让它可以滚动 为了实现这一点,我在div上设置了css属性:Css 使div可滚动并显示伪元素,css,scroll,overflow,Css,Scroll,Overflow,我有一个很长的货币div,我想让它可以滚动 为了实现这一点,我在div上设置了css属性: overflow-y: auto; height: 200px; 这起到了作用,使div可以滚动,但我有一个问题:您在图片中看到的向上的小箭头位于伪元素::before和setoverflow-y:auto使其消失 如何使div可滚动并显示伪元素::before 以下是实际的HTML: <div class="actions dropdown options switcher-opt
overflow-y: auto;
height: 200px;
这起到了作用,使div可以滚动,但我有一个问题:您在图片中看到的向上的小箭头位于伪元素::before
和setoverflow-y:auto主div上的code>使其消失
如何使div可滚动并显示伪元素::before
以下是实际的HTML:
<div class="actions dropdown options switcher-options active">
::before
<div class="action toggle switcher-trigger active" id="switcher-currency-trigger" data-toggle="dropdown" data-trigger-keypress-button="true" aria-haspopup="true" aria-expanded="true" role="button" tabindex="0">
<strong class="language-EUR">
<span>EUR - Euro</span>
</strong>
</div>
<ul class="dropdown switcher-dropdown" data-target="dropdown" aria-hidden="false">
::before
<li class="currency-ALL switcher-option">
<a href="#">ALL - Albanian Lek</a>
</li>
<li class="currency-ARS switcher-option">
<a href="#">ARS - Argentine Peso</a>
</li>
<li class="currency-AUD switcher-option">
<a href="#">AUD - Australian Dollar</a>
</li>
<li class="currency-BYN switcher-option">
<a href="#">BYN - Belarusian Ruble</a>
</li>
<li class="currency-BZD switcher-option">
<a href="#">BZD - Belize Dollar</a>
</li>
<li class="currency-BAM switcher-option">
<a href="#">BAM - Bosnia-Herzegovina Convertible Mark</a>
</li>
<li class="currency-BRL switcher-option">
<a href="#">BRL - Brazilian Real</a>
</li>
<li class="currency-GBP switcher-option">
<a href="#">GBP - British Pound</a>
</li>
<li class="currency-BGN switcher-option">
<a href="#">BGN - Bulgarian Lev</a>
</li>
<li class="currency-CAD switcher-option">
<a href="#">CAD - Canadian Dollar</a>
</li>
<li class="currency-CLP switcher-option">
<a href="#">CLP - Chilean Peso</a>
</li>
<li class="currency-CNY switcher-option">
<a href="#">CNY - Chinese Yuan</a>
</li>
<li class="currency-COP switcher-option">
<a href="#">COP - Colombian Peso</a>
</li>
<li class="currency-CRC switcher-option">
<a href="#">CRC - Costa Rican Colón</a>
</li>
<li class="currency-HRK switcher-option">
<a href="#">HRK - Croatian Kuna</a>
</li>
<li class="currency-CUP switcher-option">
<a href="#">CUP - Cuban Peso</a>
</li>
<li class="currency-CZK switcher-option">
<a href="#">CZK - Czech Koruna</a>
</li>
<li class="currency-DKK switcher-option">
<a href="#">DKK - Danish Krone</a>
</li>
<li class="currency-DOP switcher-option">
<a href="#">DOP - Dominican Peso</a>
</li>
<li class="currency-EGP switcher-option">
<a href="#">EGP - Egyptian Pound</a>
</li>
<li class="currency-HKD switcher-option">
<a href="#">HKD - Hong Kong Dollar</a>
</li>
<li class="currency-HUF switcher-option">
<a href="#">HUF - Hungarian Forint</a>
</li>
</ul>
</div>
::之前
欧元-欧元
::之前
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
您可以将::before
元素移动到具有固定高度的div
的父元素(如果有)
如果这不是一个选项,您可以向ul
元素添加包装器吗
然后可以将::before
添加到父元素中。类似于。谢谢,但遗憾的是我无法将::before元素移动到父元素,因为后者已经有了自己的::before伪元素。我用实际的HTML更新了这个问题。@KaMZaTa你能不能再给ul
添加一个包装器元素?