Forum Moderators: not2easy

Message Too Old, No Replies

Mysterious divs!

         

monkey_man

7:30 am on Nov 26, 2008 (gmt 0)

10+ Year Member



Hello!

I'm new to this forum and also fairly new to the world of css - so please bear with me :)

I create websites using seperate divs to put my content in. I've always wondered if it's possible to group multiple divs so they can be repeated further on down the page?I'm kind of bored with coding up the same div but in a different position.

Is it a case of placing them within another div? If so how is this done?

I hope I haven't opened one hefty can of worms!

Cheers.

tonynoriega

8:14 pm on Nov 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you are about to get neck deep in night crawlers my friend....

not entirely sure i understand the question though...

I create websites using seperate divs to put my content in.
got that part.

I've always wondered if it's possible to group multiple divs
yes...

they can be repeated further on down the page?

what do you mean further down the page? do you mean height wise? or just more divs down the page?

I'm kind of bored with coding up the same div but in a different position
this to me sounds like you are using inline styles and not a stylesheet?

if you are using the same div in different positions i would imagine your page looking somethign like:

<div id="old-faithful" style="float:left; height:100px; width:500px; .......">content here</div>

<div id="old-faithful" style="float:right; height:100px; width:500px; .......">content here</div>

just repeating the same DIV as you mention, just in a different position....

are you using a stylesheet? i.e. style.css

monkey_man

7:37 am on Nov 27, 2008 (gmt 0)

10+ Year Member



Hey! Cheers for the reply. What I would normally do is code up each div separately in the <style> part of my page specifying the position of it on the page. Then when I've got the page layout working, copy and paste this into a style sheet and link my page to it.

Also, in the body of my page I would use <div class="old-fathful" instead of <div id="old-faithful". Am I not doing it correctly?

I guess what i'd like to do is repeat the divs further on down the page but without constantly coding up new ones in my <style> specifying the position of them - just re using the same one again.

I'm confusing myself now ha ha! The problem is i'm self taught so i'm blagging it a bit. Would be awesome if you could set me straight tho!

Cheers.

swa66

9:36 pm on Nov 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A class might be what you seek

in CSS:


.example {
border: 1px solid green;
}

in html:

...
<p class="example">I'm an example</p>
...
<p class="example">I'm a second example and we share the same CSS</p>
...

Any element can be styled not just div-s ...