Solved

HTML/CSS - Box model troubles

Posted on 2014-07-23
3
487 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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 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…
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

735 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