css - Header breaks a apart when resizing browser window -


i've got simple page header element consisting of logo image within anchor tag nested in h1 element , nav element 4 links. below i've got 2 elements each holding image , text. i'm wondering why header breaks apart when resize browser window, , why text not wrap around respect images , landing right of them. i've noticed when hover passed logo there's slight area still link shouldn't be. i'd appreciate assistance here, i'm looking understand what's happening under hood css.

http://s27.postimg.org/7eyff3ivn/header_break1.png

http://s28.postimg.org/fwg9lohjh/header_break2.png

html

<!doctype html> <html lang="en"> <head>    <meta charset="utf-8">    <title>acme</title>    <meta name="viewport" content="width=device-width, initial-scale=1">    <meta name="description" content="">    <link rel="stylesheet" href="layout.css"> </head>  <body>        <header>     <h1><a href="index.html"><img src="images/logo.png" alt="respond"></a></h1>          <nav>               <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>         </nav>      </header>      <section class="first">          <h2>image 1</h2>          <figure>                 <img src="images/featured.png" alt="image 1" />         </figure>          <p>lorem ipsum dolor sit amet, et eum vocibus neglegentur, id nisl quidam<br>             melius nam. agam inani vel ei, reque putent oportere qui ad. cum<br>              autem veniam in, soluta everti volumus no ius. utinam tritani est ex,<br>              mei decore putent vidisse ne, justo nulla eirmod duo. te liber<br>              libris adolescens eos, id regione gloriatur neglegentur pri. mei sanctus deleniti repudiandae<br>              at, sit tritani fabulas dissentias et, salutandi vituperata vim ex.</p>      </section>      <section class="second">          <h2>image 2</h2>          <figure>            <img src="images/featured.png" alt="image 2" />         </figure>          <p>lorem ipsum dolor sit amet, et eum vocibus neglegentur, id nisl quidam             melius nam. agam inani vel ei, reque putent oportere qui ad. cum<br>              autem veniam in, soluta everti volumus no ius. utinam tritani est ex,<br>              mei decore putent vidisse ne, justo nulla eirmod duo. te liber<br>              libris adolescens eos, id regione gloriatur neglegentur pri. mei sanctus deleniti repudiandae<br>              at, sit tritani fabulas dissentias et, salutandi vituperata vim ex.</p>      </section>      <footer>             <p id="copyright">&copy; 2014 acme</p>     </footer>  </body> </html> 

css

/* reset ------------------------------------------------------------ */ * { margin: 0; padding: 0; } html { overflow-y: scroll;} body { background:#ffffff; font-size: 16px; color: #666666; font-family: arial, helvetica, sans-serif;} ol, ul { list-style: none; margin: 0;} ul li { margin: 0; padding: 0;} h1 { margin-bottom: 10px; color: #111111;}   a, img { outline: none; border:none; color: #000; font-weight: bold; text-transform: uppercase;} p { margin: 0 0 10px; line-height: 1.4em; font-size: 1.2em;} img { display: block; margin-bottom: 10px;} aside { font-style: italic; font-size: 0.9em;} article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {      display: block;     }  /*  structure   */ body {     font-family: helvetica neue, helvetica, arial;     background: white;     color: #555; }  header {   width: 100%;   overflow: auto;   border-bottom: 1px solid black;  }  /* logo h1 */ header h1 {   float: left; }  header h1 {   display: block;   text-decoration: none;   margin-top: .5em;   margin-left: 5.5em;   width: 25%; }  /* navigation*/  nav {   width: 75%;   overflow: auto; }  ul {   float: right;   list-style-type: none;   margin: 0;   padding: 0;   margin-right: 20em;  }  ul li {   float: left; }  ul li {   display: block;   text-decoration: none;   margin: 5px;   margin-top: 1.5em;   padding: 2px;   font-size: 1.2em; }  ul li a:hover {   border-bottom: 1px solid #6fc36e; } /* content*/ section {   text-align: center;   margin: 0.625em auto;   overflow: auto; }  section h2 {   margin-top: 1em;   margin-bottom: 1em; }  section img {   max-width: 100%; }  .first {   width: 45%;   float: left;   margin-left: 2%; }  .first figure {   width: 75%; }  .second {   width: 45%;   float: left;   margin-left: 2%; }  .second figure {   width: 75%; }   /* footer*/ footer {   clear: both;   text-align: center; } 

this answer addresses problems having navigation.

i remove following properties ul in css.

float: right; margin-right: 20em; 

you don't need float menu right , margin decreases available space menu. 75% width set in css should enough constrain menu size.

the wrapping of nav occur when width of nav less width of elements in menu. if want prevent can enlarge width of nav or take different approach.

hope helps.


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -