css - Why is HTML span stacking vertically? -
on website have 2 spans : "services" , "products" in top right corner (in gray strip). reason being stacked vertically, expect them align horizontally, since spans markup marksup text inside text block.
snippet :
<div id="access"> <div> <a href="#"> <span>services </span> </a> <a href="#"> <span>products</span> </a> </div> </div>
this css problem think
#access { /* background: #74c20e; background: #716417;*/ display: block; float: left; margin: 5px auto; background-color:rgb(181, 197, 207); -moz-border-radius: 0px; border-radius: 0px; width: 1200px; <!-- width: 940px; --> } #access .menu-header, div.menu { font-size: 13px; margin-left: 12px; width: 928px; } #access .menu-header ul, div.menu ul { list-style: none; margin: 0; } #access .menu-header li, div.menu li { float: left; position: relative; } #access { color: white; display: block; line-height: 38px; padding: 0 10px; text-decoration: none; } #access ul ul { box-shadow: 0px 3px 3px rgba(0,0,0,0.2); -moz-box-shadow: 0px 3px 3px rgba(0,0,0,0.2); -webkit-box-shadow: 0px 3px 3px rgba(0,0,0,0.2); display: none; position: absolute; top: 38px; left: 0; float: left; width: 180px; z-index: 99999; } #access ul ul li { min-width: 180px; } #access ul ul ul { left: 100%; top: 0; } #access ul ul { background: #0f9195; line-height: 1em; padding: 10px; width: 160px; height: auto; } #access li:hover > a, #access ul ul :hover > { background: #635ba9; color: #fff; } #access ul li:hover > ul { display: block; } #access ul li.current_page_item > a, #access ul li.current-menu-ancestor > a, #access ul li.current-menu-item > a, #access ul li.current-menu-parent > { color: #fff; }
fiddle here
does know why being displayed vertically rather horizontally?
span
elements inline default, unless overridden , still inline on page. it's parents a
elements problem. relevant page structure looks this:
<div id="access"> <div> <a href="#"> <span>services </span> </a> <a href="#"> <span>products</span> </a> </div> </div>
in css you've set
#access a{ display: block; }
this cause anchors become block level elements, , stack on top of each other, independently of behavior of spans. remove display: block
#access a
, it'll work expected.
i suggest familiarize chrome (or other one) debugger https://developers.google.com/chrome-developer-tools/docs/elements let inspect page , narrow these issues down inspecting element , eyeballing styles being applied.
Comments
Post a Comment