html - How to align aside as sidebar? -


i working on page employees biography 1 picture. biography (content) display on left , photo of employee on right sidebar. page have footer full width.

i used css layout page, , float:left both content , photos , set width divided accordingly, photo (aside) not display on right , appear under content, used display:inline properties both content , aside. trying display aside on right side of article.

article, h1, aside, footer {    padding: 20px;  }    h1 {    width: 100%;    background-color: gray;  }    article {    width: 60%    float: left;    display: inline;  }    aside {    width: 40%;    float: left;    display: inline;  }    footer {    width: 100%;    background-color: gray;    clear: both;  }
<body>    <article>      <h1>biography</h1>      <p>general information goes here</p>      <p>rest of information goes here</p>    </article>    <aside>      <h2>employee photo</h2>      <img src="http://placehold.it/350x150" />    </aside>    <footer>      <p>copyright goes here</p>    </footer>  </body>

a couple of issues should corrected:

  1. you have width set 60% , 40% article , aside, have padding:20px, make total width on 100%, easy fix set box-sizing:border-box, makes padding part of % width.

  2. if set float:left on element, turns replaced element, display:inline or block won't take effects.

  3. there syntax error, it's missing ; @ end of width: 60%.

  4. it better set img {max-width:100%; height:auto;}, make responsive.

below updated example:

* {    box-sizing: border-box;  }    article, h1, aside, footer {    padding: 20px;  }    h1 {    background-color: gray;  }    article {    width: 60%;    float: left;  }    aside {    width: 40%;    float: left;  }    footer {    background-color: gray;    clear: both;  }  img {    max-width: 100%;    height: auto;  }
<body>    <article>      <h1>biography</h1>      <p>general information goes here</p>      <p>rest of information goes here</p>    </article>    <aside>      <h2>employee photo</h2>      <img src="http://placehold.it/350x150" />    </aside>    <footer>      <p>copyright goes here</p>    </footer>  </body>


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -