Solved

HTML/CSS - Box model troubles

Posted on 2014-07-23
3
486 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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
What does GoogleTagMgr javascripts below do 5 35
tiny glitch in my main slider 3 39
Need HTML output in powershell line by line 3 28
Javascript 2 24
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

828 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