Solved

HTML/CSS - Box model troubles

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

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Detecting robots? 5 34
jQuery CSS Scroll Issue 3 30
How can i make a popup form from clicking on a button 4 18
HTML CSS 7 15
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
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.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

707 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

12 Experts available now in Live!

Get 1:1 Help Now