I would like the navigation links on this page to each appear on their own line:
A. Without using "display:block
" - as that makes the hover animation take up the full width of the container, not just the <a>
element.
B. Without using <br>
tags, as I am eventually looking to create a responsive site with a horizontal navigation on smaller screens.
Thanks for your help.
Have you tried float:left; clear:left
?
wrap you navigation in ul, li:
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
<li><a href="#">Link 4</a></li>
</ul>
css:
ul {list-style: none} li {display: block}
This lets you style your anchors accordingly while forcing them to break lines.
You can wrap the <a>
's in <div>
's and apply CSS to the div
's to float:left
, clear:left
;
div.anchorContainer
{
float:left;
clear:left;
}
<div class="anchorContainer">
<a href="#">text</a>
</div>
<div class="anchorContainer">
<a href="#">text</a>
</div>
<div class="anchorContainer">
<a href="#">text</a>
</div>