Solved

Div extending beyond container

Posted on 2014-10-07
4
295 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Title # Comments Views Activity
Slow Down an Animation 3 29
Sticking text to shapes in Raphael.js 6 41
Jquery syntax 12 30
CSS - display the same fonts throughout website. 4 29
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

752 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