Solved

Div extending beyond container

Posted on 2014-10-07
4
300 Views
Last Modified: 2014-10-07
I have a CSS class called "news".  It's within another div with a class called "content-wrapper".  When I add a 15px padding to the "news" class it pushes the left side beyond the "content-wrapper" div.  How do I fix this?

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>CSS Width Issue</title>
    <style type="text/css">
        .container {
            width: 100%;
            background-color:aqua;
            padding: 25px
        }

        .content-wrapper {
            width: 350px;
            background-color: red;  
            margin: 0 20px 0 0;
            float:left;  
            padding: 15px;        
        }

        .news {
            width: 100%;
            padding: 15px;
            background-color: blue;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div class="container">
        <div class="content-wrapper">
            <div class="news">
                Here's My News!
            </div>
        </div>
    </div>
    </form>
</body>
</html>

Open in new window

0
Comment
Question by:cdemott33
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40367137
Add this css

* {
    box-sizing: border-box;
}

Open in new window

0
 

Author Comment

by:cdemott33
ID: 40367313
Hi Gary,

Sorry, no luck.  I even tried to remove the float: left to see if that was messing things up and it isn't.  Here's a screen capture and my updated code.  Any other ideas?

css-issue.jpg
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>CSS Width Issue</title>
    <style type="text/css">
		* {
		box-sizing: border-box;
		}

        .container {
            width: 100%;
            background-color:aqua;
            padding: 25px
        }

        .content-wrapper {
            width: 350px;
            background-color: red;  
            margin: 0 20px 0 0;
            padding: 15px;        
        }

        .news {
            width: 100%;
            padding: 15px;
            background-color: blue;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div class="container">
        <div class="content-wrapper">
            <div class="news">
                Here's My News!
            </div>
        </div>
    </div>
    </form>
</body>
</html>

Open in new window

0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40367320
Code is working fine.

http://jsfiddle.net/3phpuswm/
0
 

Author Comment

by:cdemott33
ID: 40367343
Looks like you helped me figure out the problem.  It turns out that I needed to remove this...

<!DOCTYPE html>

Open in new window


... from the top of the page and it worked.   Thanks for your help!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question