html5 - Controlling glyphicon spacing and text link within a unordered list for a horizonatial nav menu -
how control vertical spacing between 2 items stacked, centered , vertically within unordered list item? glyphicon on top of text link within unordered list item in navigation menu.
what css rules such thing happen.
<!doctype html> <html lang="en-us"> <meta charset="utf-8" /> <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" title="style"> <head> <style type="text/css"> /* adding display: inline-block; style attribute display content horizontally. add nav's <li> elements in css. i'm guessing every <li> may have glyph. add text-align:center on <li>'s within nav in css align <li>'s content in middle. */ *{ margin:0; padding:0; } /* target 1 icon, */ .glyphicon.glyphicon-globe { padding:3px 0 0 0; margin: 0 0 -15px 0; font-size: 17px; } nav { width: 100%; height:50px; line-height:50px; text-align:center; background:#87e0fd; color:#f00; } nav ul { margin:0; padding:0; width:100%; line-height:50px; height:auto; list-style:none; } nav li { display: inline-block; width:110px; height:50px; text-align:center; text-decoration: none; padding:auto; margin:0; border-left: solid 1px #999; } /* puts border on right side of menu */ nav li:last-child { border-right: solid 1px #999; } /* target hover action or active write css below. */ nav li:hover { text-decoration: none; background:#3f4c6b; color:#fff; cursor:pointer; } nav li:active { text-decoration: none; margin: -15px 0 0 0; } </style> <title>my glyphicon navigation menu </title> </head> <body> <nav> <ul> <li> <link href="#" title="home"> <span class="glyphicon glyphicon-globe"></span><br> <span class="glyphicon-class">home</span> </link> </li> <li> <link href="#" title="about"> <span class="glyphicon glyphicon-globe"></span><br> <span class="glyphicon-class">about</span> </link> </li> <li> <link href="#" title="contact"> <span class="glyphicon glyphicon-globe"></span><br> <span class="glyphicon-class">contact</span> </link> </li> </ul> </nav> <p>hello world</p> </body> </html>
this example on how can it, adding css :
/* adding margin between glyphicon , text */ .glyphicon-class { display:block; margin-top:50px; }
here fiddle : http://jsfiddle.net/b6tabykq/1/
if wanted remove spaces, don`t know wanted to, should remove < br > tag in html..
fiddle : http://jsfiddle.net/b6tabykq/2/
Comments
Post a Comment