![]() |
|
||||||||||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|||||
|
|
#1 |
|
WLC Member
Join Date: Jul 2012
Posts: 1
|
Hi,
I'm experimenting with media queries targeting the viewport, and have a peculiar problem. I have a very basic layout using a wrapper, header, nav, main content, aside & footer using percentages for layout. Wrapper is set at 80% and all elements are contained in the wrapper. Header, nav & footer within the wrapper is set at 100%. Main content (75%) is floated left, aside (25%) to the right. Everything looks fine when resizing the browser to different sizes, but when I target a specific viewport, and then remove the floats (so that the aside drops down vertically below the main content), the content in the aside jogs to the right about 45px after it drops below the main content. I'm puzzled! I'm using a reset which sets the following for most elements: margin: 0; padding: 0; border: 0; font-size: 100%; For html5: article,aside,details,figcaption,figure, footer,header,hgroup,menu,nav,section { display: block; } Here are the two elements and the changes between "normal" and the query. Before media query: .main{width:75%;height:auto;position:relative;floa t:left;clear:right;} aside{width:25%; height:auto; position:relative;float:right;} After query: @media only screen and (min-width: 320px) and (max-width: 640px) { .main{width:95%;height:auto;position:relative;} aside{width:95%;height:auto;position:relative;} } Wrapper is not changed for the media query, and is set for width:80%; overflow:auto; margin:0 auto;. I can solve the problem by floating both to the left, like so: .main{width:95%;height:auto;float:left;} aside{width:95%;height:auto;float:left;} But I'm trying to figure out why this is neccessary. Why is the main content positioned correctly, but the aside moves to the right? They should be positioned the same with the same parameters, shouldn't they? Hopefully someone here has an explanation, 'cause I'm stumped! Thank you. Doug |
|
|
|
|
|
#2 |
|
WLC Mod
Join Date: Jul 2009
Location: Milky Way Galaxy
Posts: 3,167
|
Do you have a live link?
Also, can you toss a button in there to simulate the code as being on a specific view port?
__________________
Praise be to the Lord God for the ability to learn, the capability to analyze, and the time to help users on this forum. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
Linear Mode |
|
|