I build HTML/CSS/JS menu and want to align arrow to the right to point that this element is submenu.
My problem that in Firefox triangle ("▶" sign) shown on next line instead of current line...
Chromium shown both cases fine.
There are bugs in BTS that similar to my situation:
I try 2 strategy, this my HTML structure:
<div class="name1">Submenu 1<span class="sub">▶</span></div>
<a href="#">Item 1</a>
<a href="#">Item 2</a>
<div class="name2">Submenu 2</div>
<a href="#">Item 1</a>
<a href="#">Item 2</a>
and this my CSS which shown issue:
a, .name1, .name2 {
display: block;
white-space: nowrap;
}
.name1 > .sub {
float: right;
}
.name2:after {
content: "▶";
float: right;
}
JS Fiddle for playground.
I remember I read code where margin-right: -16px
or similar used with background image or something else to make such design but I can't remember exactly how.
What workaround possible?
UPDATE I make more complete example, HTML:
<div class="container">
Top level menu
<div class="box">
<div class="name1">Very long submenu 1<span class="sub">▶</span></div>
<a href="#">Item 1 1 1</a>
<a href="#">Item 2</a>
<div class="name2">Very long submenu 2</div>
<a href="#">Item 1</a>
<a href="#">Item 2</a>
</div>
</div>
CSS:
a { border: green 1px dotted; margin: 2px; }
a, .name1, .name2 {
display: block;
white-space: nowrap;
}
.name1 > .sub {
display: inline-block;
float: right;
}
.name2:after {
content: "▶";
float: right;
}
.container {
display: inline-block;
background: gold;
position: relative;
}
.box { display: none; }
.container:hover > .box {
display: block;
position: absolute;
top: 100%;
}
getting rid of "white-space: nowrap" helps
Finally I solve problem:
and:
Essential part is to make element with triangle as
block
andposition: relative
and reserve space for triangle bypadding-right: -1.2em
and position triangle byposition: absolute
after element and move back triangle bymargin-left: -1em
.