Solved

HTML/CSS - Box model troubles

Posted on 2014-07-23
3
479 Views
Last Modified: 2014-07-24
Hi,

I'm having trouble with this particular box model template. The code was operational until I implemented another container. The problem is in its current state, the CSS for the most inner elements do not work (boxheader/boxbody - i.e. background colors don't work etc). I was hoping to get one entire panel operational before adding the additional 3 to the right. The headers will be unique for each panel (both in colour & text) hence why I've opted for this structure. I'm then looking to insert clickable buttons in the body containers.

Any ideas on my current problem and the best way to achieve the desired state?

Thanks

Target state
 Target state
CSS
#container {
	position: absolute;
	padding: 10px;
	margin: 270px auto auto 180px;
	width: 1500px;
	height: 650px;
	border-style:solid;
	border-color: #0000ff;
}

#boxcontainer {
	position: relative;
	padding: auto;
	margin: auto;
	width: 400px;
	height: 590px;
	border-style:solid;
	border-color: #ff0000;
	float: left;
	overflow: hidden;
}

#boxcontainer.boxheader {
	position: relative;
	text-align: left;
	width: 350px;
    	padding: 1px 1px 1px 1px;
	background-color: #0066FF;
	color: #FFFFFF;
	font-size: 18px;
	font-weight: bold;
	float: left;
}

#boxcontainer.boxbody {
	position: relative;
	text-align: left;
	width: 350px;
    	padding: 1px 1px 300px 1px;
	background-color: rgb(77,77,77);
	color: #FFFFFF;
	font-size: 18px;
	font-weight: bold;
	float: left;
}

Open in new window


HTML
<head> 
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<div id="container">
     <div id="boxcontainer">
          <div class="boxheader">Header Panel 1</div>
          <div class="boxbody">Body 1</div>
     </div>
</div>

Open in new window

0
Comment
Question by:just4kix
3 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40215477
Remove "#boxcontainer" from "#boxcontainer.boxheader" and "#boxcontainer.boxbody".  I don't know the rule but it is interfering.
0
 
LVL 20

Accepted Solution

by:
Russ Suter earned 500 total points
ID: 40215510
There are a few things going on here.

First off, your HTML markup is incorrect.

It should look more like this:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link href="css/style.css" rel="stylesheet"/>
</head>
<body>
<div id="container">
     <div id="boxcontainer">
          <div class="boxheader">Header Panel 1</div>
          <div class="boxbody">Body 1</div>
     </div>
</div>
</body>
</html>

Open in new window


Second, your style sheet is relying on the id property. This will work fine for one instance but to add 3 more like you're suggesting will cause collisions. You might want to consider setting styles based on class rather than id.

Third, your inheritance rules are off. If you need to constrain your class definition you need to use a space rather than a dot. I'd also specify that you're only applying this to a div element. It would look more like this:

div#boxcontainer div.boxheader

Open in new window

0
 

Author Closing Comment

by:just4kix
ID: 40217534
Thank you, works a treat
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
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 learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now