?
Solved

HTML/CSS - Box model troubles

Posted on 2014-07-23
3
Medium Priority
?
493 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
[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
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 2000 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

777 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