Forum Moderators: not2easy

Message Too Old, No Replies

combining property of the same attribute together?

         

fukchai2000

5:49 am on Jan 19, 2005 (gmt 0)

10+ Year Member



hi guys,

i have the following HTML....
<div position="absolute" top="10" left="12"></div>
<div position="absolute" top="10" left="30"></div>
<div position="absolute" top="10" left="40"></div>
<div position="absolute" top="10" left="60"></div>

can we combine the position into one in CSS?

DIV{position="absolute"}......(something like these?)

and the positioning on the window is still remain the same?

cornelius

12:31 pm on Jan 19, 2005 (gmt 0)

10+ Year Member



hi

Yes you can do that, but if you use

div{position:absolute;}

all of the divs in the page will use absolute positioning, unless you specify otherwise.

My advice would be to use something like:

.abs{position:absolute;}

and then just attach the class to the div like so:

<div class="abs" top="10px" left"12px"> etc...

you can also add the top:10px to the class in css and then you don't need to add that to every div.

In the end, you should create a class for every div in your css and just attach the classes to the divs. It just makes more sense if you're gonna use css in any case.

Hope you find this helpfull

Cor

BonRouge

12:43 am on Jan 20, 2005 (gmt 0)

10+ Year Member



I'm sorry, but all this is... wrong.

This :

<div position="absolute" top="10" left="12"></div>
<div position="absolute" top="10" left="30"></div>
<div position="absolute" top="10" left="40"></div>
<div position="absolute" top="10" left="60"></div>

is way off the mark. That's not html. There are no 'position', 'top' or 'left' properties in html.
You want to write yourself some css.

Something similar to this might look like this :

<div class="abs" id="a"></div>
<div class="abs" id="b"></div>
<div class="abs" id="c"></div>
<div class="abs" id="d"></div>

with some css like this :
.abs {position:absolute; top:10px;}
#a {left:12px;}
#b {left:20px;}
#c {left:40px;}
#d {left:60px;}

However, I suspect that there is a better way to do what you want to do (though it would help if I knew exactly what you were trying to do).

Could you possibly post some more code and explain what you're after?

rocknbil

1:22 am on Jan 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The above is better, but the equivalent inline is

<div style="position:absolute; top:10; left:12;">

BonRouge

1:36 am on Jan 20, 2005 (gmt 0)

10+ Year Member



I'm sorry, but it isn't. In css, you have to say what you're talking about. Is it 10 camels, 10 sheep, 10 pixels, 10 per cent? You have to be specific. Besides that, inline styles are just bad practice - css should be either in the head or - better - in an external .css file.