Click to See Complete Forum and Search --> : div nesting code check
GJPG5
05-11-2005, 09:22 AM
well, can't seem to get this to work properly, I may or may not be nesting the divs correctly
the positioning of the divs is fine, but I can't seem to get the position of the .divnest class to move where I want it to. Any suggestions?
p {
font-family: Arial, Helvetica, sans-serif;
font-size: 90%;
text-align: justify;
}
h1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 105%;
font-weight: bold;
}
h2 {
font-family: Arial, Helvetica, sans-serif;
font-size: 110%;
font-weight: bold;
}
div {
background-color: #CCCCCC;
border: 1px solid;
padding: 25px 5px 8px;
background-image: url(/Images/box.gif);
margin-right: auto;
margin-left: auto;
position: absolute;
visibility: visible;
}
.divnest {
margin-right: auto;
margin-left: auto;
position: absolute;
left: auto;
right: auto;
}
body {
font-size: 76%;
text-align: center;
}
-->
</style>
</head>
<body background="/Images/resumhtm.jpg">
<div.nest class="Nest" style="position:relative;marign-right: auto; margin-left;auto width:567px; height:504px; z-index:1; visibility: visible;" name="Nest">
<div id="Experience" style="position:relative; margin-left: auto;float: right; width:217px; height:504px; z-index:1">
</div>
<div id="Education" style="position:relative; float:left; width:206px; height:195px; z-index:1">
</div>
<div id="Software" style="position:absolute; float:left; width:206px; height:195px; z-index:1; top: 310px;">
</div>
</div.nest>
Snitchcat
05-11-2005, 09:34 AM
Okay, this may be a dumb question, but why is it <div.nest class="Nest"> and </div.nest> instead of <div class="divnest"> and </div>? Strikes me that maybe that's the problem.
<div.nest class="Nest" style="position:relative;marign-right: auto; margin-left;auto width:567px; height:504px; z-index:1; visibility: visible;" name="Nest"> XXXXX </div.nest>
Take care,
Snitch.
GJPG5
05-11-2005, 09:39 AM
Okay, this may be a dumb question, but why is it <div.nest class="Nest"> and </div.nest> instead of <div class="divnest"> and </div>?
Take care,
Snitch.
that seemed to be the only way I could make the 3 central DIV's fit inside the main div. I wanted to use .divnest for positioning purposes, so that I could get those center divs, "resume, skills, education".
divs "resume, skills, and education" all have a specific "look" to them. Without having that "look" applied to the centering div, I created div.nest
there may be a better way to approach this, I am on day #2 of using CSS
NogDog
05-11-2005, 09:50 AM
<div.nest> is not a valid HTML tag. The value assigned to "class=" must be a class that you have defined in your CSS styles. Therefore, as Snitchcat points out, it would need to be something like "<div class=divnest>...</div>".
GJPG5
05-11-2005, 09:58 AM
Ok, like I said, I am new at this.. I'll rework it and see if what I am trying to do works. Thanks.. (thought it might be the code)
Snitchcat
05-11-2005, 10:17 AM
Is the following similar to what you wanted?
p {
font-family: Arial, Helvetica, sans-serif;
font-size: 90%;
text-align: justify;
}
h1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 105%;
font-weight: bold;
}
h2 {
font-family: Arial, Helvetica, sans-serif;
font-size: 110%;
font-weight: bold;
}
div {
background-color: #CCCCCC;
border: 1px solid;
padding: 25px 5px 8px;
background-image: url(/Images/box.gif);
margin-right: auto;
margin-left: auto;
position: relative;
visibility: visible;
}
.divnest {
margin-right: auto;
margin-left: auto;
position: relative;
width: 567px;
height: 560px;
}
body {
font-size: 76%;
text-align: center;
}
-->
</style>
</head>
<body background="/Images/resumhtm.jpg">
<div class="divnest" style="z-index:1; visibility: visible;">
<div id="Experience" style="clear; both; position: relative; float: right; width: 217px; height: 504px; z-index:1;">
</div>
<div id="Education" style="position: relative; float:left; width:206px; height:195px;">
</div>
<div id="Software" style="position: relative; float:left; margin-top: 50px; width:206px; height:195px; visibility: visible;">
</div>
</div>
GJPG5
05-11-2005, 01:48 PM
Here's what I am trying to do with my resume page.
divnest is just for the purposes of positioning the nested divs., therefore the divs in the nest need to have different properties then those assisgned to divnest.
basically, I want divnest to margin-right: auto, margin-left: auto, and leave some room for spacing top down, probably between 20 - 40 pixels.
i want the blocks to the left to float left and block on the right to float right, all while mainting equal space among each other.
grey represents tiled background image, white should be transparent, no border (representing divnest), and then the dark grey blocks are all separate divs (education, software, experience)
wheelerch
05-11-2005, 05:17 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>whatever</title>
<style type="text/css">
body {
background: url('/Images/resumhtm.jpg');
font-family: Arial, Helvetica, sans-serif;
font-size: 76%;
}
p {
font-size: 90%;
text-align: justify;
}
h1 {
font-size: 105%;
font-weight: bold;
}
h2 {
font-size: 110%;
font-weight: bold;
}
div {
background: #CCC;
border: 1px solid #000;
background-image: url('/Images/box.gif');
}
#nest {
border: none;
background: none;
margin-top: 30px;
width:567px;
height:504px;
margin: 0 auto;
}
#experience {
float: right;
width: 217px;
height: 504px;
}
#education {
float: left;
clear: left;
width:206px;
height:195px;
}
#software {
float: left;
clear: left;
margin-top: 112px;
width:206px;
height:195px;
}
</style>
</head>
<body>
<div id="nest">
<div id="experience">
Experiance
</div>
<div id="education">
Education
</div>
<div id="software">
Software
</div>
</div>
</body>
</html>
Is this what your looking to do?
A few points to note:
You dont need to put a stylesheet in the document and use style="" attributes on the tags - use one or the other, preferable a style sheet, or even an external style sheet.
If you use a doctype tag (either html 4.01 strict or XHTML 1.1) Internet explorer will correctly render divs etc, and you can use the margin: auto to center things.
If your only using a div style once in a document, give it an id="name" attribute and reference it in the css as #name otherwise use class="name" and reference it as .name
Example Here (http://www.wheelerc.com/examples/gjpg5/)
Hope this helps
- Chris
GJPG5
05-11-2005, 05:19 PM
Ok Snitch, that code got me close to what I want, but I am still getting a background image on .divnest, I will see if I can tweak things a bit, but esentially, that is exactly what I want.
GJPG5
05-11-2005, 05:27 PM
<3's to Chris, in a completely non-offensive way, of course.
GJPG5
05-11-2005, 05:29 PM
Why are you using #nest, #experience, etc. in the <style> tag?
wheelerch
05-11-2005, 06:33 PM
if you use #nest it applies the style to any div with the id 'nest'...
GJPG5
05-11-2005, 06:39 PM
got it, still going over the basics, but this all makes perfect sense in a scary way
Snitchcat
05-12-2005, 10:09 AM
I think I got it. You'll have to experiment with the background images as I don't have those to take a look. For me, the code works in IE, Netscape and FF.
Notes:
I shifted 'education', 'experience', and 'software' into the header as classes -- I'm not sure how often you'll be using them, so they're a class, not id.
I also moved the background-image stuff into the stylesheet -- I'm assuming you may be using the classes multiple times, so changing the background once for each class should be enough ;)
Btw, I couldn't figure out how to stick the classes under an id and still keep the formatting. So... one background-image per class it is -- unless someone else would like to suggest something here??
The last thing I couldn't find out how to do: vertically align text in the middle. So... that's something you'll have to investigate; sorry.
Hope this helps.
Take care,
Snitch.
p {
font-family: Arial, Helvetica, sans-serif;
font-size: 90%;
text-align: justify;
}
h1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 105%;
font-weight: bold;
}
h2 {
font-family: Arial, Helvetica, sans-serif;
font-size: 110%;
font-weight: bold;
}
div {
background-color: #CCCCCC;
padding: 0;
margin-right: auto;
margin-left: auto;
position: relative;
text-align: left;
visibility: visible;
}
#nest {
background-color: #ffffff;
margin-right: auto;
margin-left: auto;
position: relative;
width: 567px;
height: 504px;
z-index:1;
visibility: visible;
}
body {
font-size: 76%;
text-align: center;
background-image: url(/Images/resumhtm.jpg);
}
.experience {
clear; both;
background-image: url(/Images/box.gif);
position: relative;
float: right;
width: 217px;
height: 100%;
z-index:1;
}
.education {
background-image: url(/Images/box.gif);
position: relative;
float:left;
width:206px;
height:195px;
}
.software {
background-image: url(/Images/box.gif);
position: relative;
float: left;
margin-top: 114px;
width:206px;
height:195px;
visibility: visible;
}
-->
</style>
</head>
<body>
<div id="nest" style="z-index:1; visibility: visible;">
<div class="Experience">experience
</div>
<div class="Education">education
</div>
<div class="Software">software
</div>
</div>
GJPG5
05-12-2005, 03:49 PM
Yeah, those headers were only used once in that. I did some cool work with what you guys helped me with. And the more I work with divs and nesting, the more my eyes open to how this works.. my previous issue was a lack of not understanding how to properly use tags and classes together.
Hopefully, my portfolio site will be ready by the weekend, and I can give you a sneak peak of what I did with it. It's simple, but I feel effective.
Unfortunately, I do not think I will be using CSS for the main part of my portfolio display, I am going to take the second half of this class, which deals exclusively with flash, and apply that to the portfolio.