问题
I'm trying to create a dropdown menu like the one here, but I haven't been successful in styling it correctly.
The menu I'm looking to create is similar to one found here
Example:
This is what I have so far!
http://jsfiddle.net/9ggfz0st/1/
@import url('http://getbootstrap.com/dist/css/bootstrap.css');
.dropdown-menu:before {
position: absolute;
top: -7px;
left: 9px;
display: inline-block;
border-right: 7px solid transparent;
border-bottom: 7px solid #ccc;
border-left: 7px solid transparent;
border-bottom-color: rgba(0, 0, 0, 0.2);
content: '';
}
.dropdown-menu:after {
position: absolute;
top: -6px;
left: 10px;
display: inline-block;
border-right: 6px solid transparent;
border-bottom: 6px solid #ffffff;
border-left: 6px solid transparent;
content: '';
}
<div class="dropdown">
<a data-toggle="dropdown" href="#">Dropdown trigger</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
Account Settings<hr>Billing
</ul>
</div>
I'm not able to center the arrow to the middle, also apply "drop down menu animation effect"
How can I center the arrow to the center?
回答1:
In order to change positioning of the arrow, simply change the left
value like so:
.dropdown-menu:before {
position: absolute;
top: -7px;
left: 40%;
display: inline-block;
border-right: 7px solid transparent;
border-bottom: 7px solid #ccc;
border-left: 7px solid transparent;
border-bottom-color: rgba(0, 0, 0, 0.2);
content: '';
}
.dropdown-menu:after {
position: absolute;
top: -6px;
left: 40%;
display: inline-block;
border-right: 6px solid transparent;
border-bottom: 6px solid #ffffff;
border-left: 6px solid transparent;
content: '';
}
JSFiddle
来源:https://stackoverflow.com/questions/29997953/dropdown-menu-with-arrow-in-center