html5 - Options for aside that can be after main content in mobile views, top right for tablet/desktop -


working on responsive design , i'm curious options positioning aside appears on top right of content area in widescreen views after main content in mobile browsers.

e.g.

here's article. [list of winners] article text can wrap around aside. article text can wrap around aside.

in html5 know use following html:

<div class="main"> <article>here's article</article> <aside>list of winners</aside> </div> 

and following css:

@media screen , (min-width:768px) { .main article {     float:left;     width:57%; } .main aside {     float:right;     width:28%; } } 

that allow me have aside next article in widescreen , below mobiles. article text not wrapped around bottom of aside , kept @ 57% width full length of page, after aside finished.

is there way achieve i'm looking or solution kludgy?

thanks.

if don't mind involving js:

http://jsfiddle.net/77nwn/2/

html:

<div class="main">     <aside class="float">list of winners</aside>     <article>         <p>here's article</p>         <p>article text can wrap around &lt;aside&gt;</p>         <p>article text can wrap around &lt;aside&gt;</p>     </article> </div> 

css:

@media {     .main aside.float {         display:none;     } } @media (min-width:350px) {     .main aside.under {         display:none;     }     .main aside.float {         display:initial;         float:right;         width:28%;     } } 

js:

window.onload=function(){     var aside=document.queryselector("div.main aside.float");     aside=aside.clonenode(true);     aside.classname="under";     document.queryselector("div.main").appendchild(aside); }; 

if don't mind using flexbox:

(inspired @dstorey)

warning: tested on chrome 26 desktop , firefox 21 desktop. compatible table / mdn guide.

http://jsfiddle.net/77nwn/3/

html:

<div class="main">     <aside>list of winners</aside>     <article>         <p>here's article</p>         <p>article text can wrap around &lt;aside&gt;</p>         <p>article text can wrap around &lt;aside&gt;</p>     </article> </div> 

css:

@media {     .main aside {         float:right;         width:28%;     } } @media (max-width:350px) { /* notice change min-width max-width */     .main {         display:-webkit-flex;         display:flex;         -webkit-flex-direction:column;         flex-direction:column;     }     .main article {         -webkit-order:1;         order:1;     }     .main aside {         -webkit-order:2;         order:2;         float:initial;         width:initial;     } } 

no js involved.

i'm not sure "old syntax" is, didn't pay attention on topic when they're discussing it...


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -