How to prevent floating divs from folding? - html

Please don't tear me a new one because this question has been asked before, but their solutions are not working.
Question: How can I prevent two floating div's from wrapping?
Here is my webpage: Defining Voice Page
At the top I have two div's, one for the logo (float-left) and one for the site nav. (float-right). The parent div has a fixed width of 930px. What I want is for the left and right div's to appear inline on opposite sides of the 930px with and remain fixed in place when the window size changes.
The problem: when you resize the window the nav. panel moves and folds/wraps.
I've tried:
1) Setting the parent div to a fixed width (930px).
2) Setting the right and left div's as 'inline'.
3) Setting the right and left div's width to 50%.
...none of those works to fix the location of these div's.
Can someone tell me the right combination of the above or is there something else going on here?
Thanks in advance,
John

Add min-width and change the display property when it reach on 850px size. At present it is like this.
header .float-left, header .float-right
{
float:none;
}
Solution 1: If you want to keep the float:none property Use like below.
#media only screen and (max-width: 850px){
header .float-left, header .float-right
{
float:none;
min-width:425px;
display:table-cell;
}
}
Solution 2: If there is NO problem to remove this float then just remove it like below.
#media only screen and (max-width: 850px){
header .float-left, header .float-right
{
}
}

Related

Div not resizing even with clear or overflow

I have 2 boxes (About Us and Contact Us) that don't change (stack) when you resize the browser. I've checked the forums and it looks like I need either a clear:both or overflow:hidden. My problem is, I've tried both of those anywhere I can think of and nothing happens.
So far, I've tried overflow in the wrapper, box1 and box2. As well as paragraphs 1-3. I've also tried clear in pretty much every spot around/in/under the wrapper div in my HTML.
When the browser reaches the 768px breakpoint, you need to change the div's display mode to block so that it doesn't allow any other item in its horizontal space.
#media (max-width: 768px) {
#box1 {
display: block;
width: 60%; /* Set according to your requirement */
}
}
Output:
JSbin

Div won't center when using #media

I am using #media queries to adjust the content of the website when the window size is changed. I have currently have 2 side-by-side divs and when the window gets below 900px, I move the one on the right below the one on the left.
I can get the bottom div (Content-Right) to center without any problem, but I can't seem to get the top one (Content-Left) to center. I've posted a link to jsfiddle for my html and css.
Any help is appreciated.
<b>JS FIDDLE BELOW</b>
http://jsfiddle.net/L0nzz8or/
I will assume by top div you mean at the bottom in the section under About EGLT. I deleted the width and used display:table. Here are the changes:
/* HOME & CONTACT PAGE STYLES */
.Content-Left {
display:table;
float: left;
overflow: hidden;
}
I had a type-o that I didn't see in my CSS.
.Content-left
should have been
.Content-Left
It was just me overlooking that type-o and having trouble seeing it.

Two column responsive issue

I am pretty new to coding in responsiveness. I usually use a wordpress theme that already has it working but I am doing a few edits to a site for someone and looking to fix their issue.
Basically there are two columns, one with float left and width: 65%, the right one with Float right and width of 30%. they scale to a point but then the right one drops down but stays beside the left one instead of under it
here is the page: http://engfind.com
Use :Media queries
You want to stack them with 100% width on tablets or on mobiles devices -.
Example:considering breakpoint to be 600px
#media (max-width: 600px){
.homePage{
width:100%;
}
.homeNews{
width:100%;
float:left;
}
}
Floating both of the divs left should do the trick. Make sure you apply overflow:hidden to the parent container or put a clearfix div below so that content below does not creep up.

How to center content in a div in responsive skeleton?

There are similar questions to this but none of them are solving this problem.
I have built my site using a skeleton framework (http://www.getskeleton.com). For some reason, when i try to apply padding or any margin greater than 5px to the content in the main div on the site, the text portion jumps below the image. I've tried using their "offset-by" classes but the same thing happens. I've tried using
margin:0 auto; on all divs in that section but to no avail. I've also tried using text-align:center; but that didn't work either (oddly, this only centers the h1 element in that section but nothing else...).
The other issue I'm having is that I want all the backgrounds to expand to fit the width of the browser window and all the content should remain in the center but that doesn't seem to work well with this layout. If I set the container div's width to 100% it does expand but I end up having to set all the column and offset-by classes to 100% as well and then that messes up the navigation, etc. I want to keep my layout how I have it now but I just want the backgrounds to expand (including footer height) and for all content to be centered.
Here is the screenshot of what it looks like in the browser: http://i.imgur.com/K3LAshv.png
Can anyone please take a look at the code and let me know what I should fix here? I've added my code on JSFiddle:http://jsfiddle.net/z9uVK/
Many thanks in advance!!
The skeleton is confusing the hell out of me, there is just so much going on... so I eliminated all CSS and added a few simple rules demonstrating the techniques I would use to code this behavior from scratch
Since you want the background color bands to extend beyond the container, I am setting the container to 100% and placing extra divs around each of header, main and footer. These have width 100% also. The width of #header, #main, footer is set to 960px by default and reduced with a media query. I have also set the columns and the headshot image to use percents instead of pixels. I also removed a couple inline style rules from the HTML because they were breaking this new code.
http://jsfiddle.net/W7wG3/1/
// part of my css:
.container{width:100%;}
#headerBin{
background-color: white;
border-top: 15px solid #4d4d4d;
}
#header, footer, #main{
width: 960px;
margin:auto;
}
#media only screen and (min-width: 768px) and (max-width: 959px) {
#header, footer, #main{
width: 768px;
margin:auto;
}
}

How to clear absolute positioned items on window resize?

So by default, an absolute positioned div will fall out of view if the window is resized, but only the left side of the div. Is it possible to achieve the same effect to the right?
What I mean can be found here: http://diabetes.connectionsquad.com
If you resize the browser window to anything below 1010px you'll notice the left side of the navbar disappears, but if you scroll right, the right side of the nav bar stays in position.
Basically I have content div that is set to 1000px. My navbar is 1050 and it is centered in that content div with absolute position, so it hangs over the content div 25px on each side. When the browser size falls below 1050px, I want that 25px area to collapse and not be visible. By default browsers do this on the left, but not the right.
Can you clear the right side the same way you can clear the left? I tried researching it, but I got a bunch of junk because the search terms get skewed.
I can't see the problem on Chrome. However, you're not setting top or left, it defaults to 0,0 for top and left, so it is attached to the top left corner of its relative parent. If you want it to be attached to the top right, you can give it
right: 0;
top: 0; /* Don't need this, it's the default;
By "out of view", I am taking it you mean out of your set content width.
Have a look at negative positioning. left:-20px; right:-20px
<style type="text/css">
div { position:absolute; left:-20px; right:-20px }
</style>
Hope helps,
Rob
Your layout doesn't require any absolute positioning, and it will give you monster headaches.
Rather than using a fixed width div in the center, you can do an outer margin or outer padding which is flexible.
/*Mobile*/
.outermargin {padding:0% 0% }
/*Screen*/
#media only screen
and (min-width : 700px) {
.outermargin { padding: 0% 7%; }
}
#media only screen
and (min-width : 1400px) {
.outermargin { padding: 0% 20%; }
}
Use margin or padding depending on your needs... This CSS structure is one way to be more fluid and easier once you are used to it.
Or you could have centered it all using something like:
#mycontainer {
margin: 0 auto; max-width:30em; }