html - How to prevent horizontal scroll? -
html - How to prevent horizontal scroll? -
currently code looks
class="snippet-code-css lang-css prettyprint-override">body { padding: 0px; margin: 0px; background-color: #aba49f; font-family: verdana, geneva, sans-serif } .header_bar { width: 100%; height: 45px; z-index: 1000 !important; box-shadow: 0px 2px 12px rgba(0, 0, 0, 0.506); height: 22px; padding: 7px 40px; background-image: linear-gradient(to top, #212121 9%, #181818 100%); border-bottom: 2px solid #606060; } .header_content { width: 50%; margin: left; } .header_content li { list-style: none; float: left; font-size: 15px; } .title li { color: #ffc900 !important; } .header_content li { text-decoration: none; color: white; margin-right: 30px; } .header_content a:hover { color: #ffc900; } .sidebar_frame { z-index: 111; position:absolute; top:0; bottom:0; left:0; width:50px; background:#000; }
class="snippet-code-html lang-html prettyprint-override"><div class="sidebar_frame">aaaa</div> <div class="header_bar"> <div class="header_content"> <div class="title"> <li><a href=""><b>farm</b></a> </li> </div> <li><a href="">new farm</a> </li> <li><a href="">aaaa</a> </li> <li><a href="">aaaa</a> </li> </div> </div>
i tried create sidebar 100% height. have no thought why sidebar without z-index on top of menu , why there random scrollable space on pages horizontal axis?
removing sidebar cleans scrollable space.
the sidebar overlapping menu because position: absolute
elements are removed normal flow of document. means header positioning without regard sidebar.
to prepare overlap:
give left-margin
.header_bar
same width of sidebar. accommodates space side bar.
to prepare scrolling issue:
remove left , right padding .header_bar
, apply left padding .title
remove 100% width of .header_bar
a few little improvements:
remove <li>
, apply styles straight elements
remove or increment width of .header_content
remove margin: left
not exist
place .title a
after other links properties in css. when property values conflict, lastly property declared winner. this eliminates need !important
.
remove z-index properties; no longer required.
put , example:
class="snippet-code-css lang-css prettyprint-override">body { padding: 0px; margin: 0px; background-color: #aba49f; font-family: verdana, geneva, sans-serif } .header_bar { height: 45px; box-shadow: 0px 2px 12px rgba(0, 0, 0, 0.506); height: 22px; padding: 7px 0; background-image: linear-gradient(to top, #212121 9%, #181818 100%); border-bottom: 2px solid #606060; margin-left: 50px; } .header_content .title { list-style: none; float: left; font-size: 15px; padding-left: 40px; } .header_content { text-decoration: none; color: white; margin-right: 30px; float: left; } .title { color: #ffc900; } .header_content a:hover { color: #ffc900; } .sidebar_frame { position: absolute; top: 0; bottom: 0; left: 0; width: 50px; background: #000; }
class="snippet-code-html lang-html prettyprint-override"> <div class="sidebar_frame">aaaa</div> <div class="header_bar"> <div class="header_content"> <div class="title"> <a href=""><b>farm</b></a> </div> <a href="">new farm</a> <a href="">aaaa</a> <a href="">aaaa</a> </div> </div>
html css
Comments
Post a Comment