1

so I'm just starting my career as a web designer, working on my first project now, i just finished the first page design, but anyway i have some worries about the css design that I created, mainly about positioning the html elements. here's the code samples:

.contentbackground
{
   background-image: url('../images/body/BG.png');
   width: 1218px;
   height: 370px;
   position: absolute;
   top: 205px;
   margin-left: 67px;
}
.loginbox
{
   width: 351px;
   height: 280px;
   position: absolute;
   top: 40px;
   right: -12px;
}
.lblLogin
{
   position: absolute;
   top: 85px;
   right: 265px;
   font-family: "Century Gothic";
   font-size: 16px;
   color: #FFFFFF;
}

the question is, is this approach the best practice? i mean, set the position absolute, and manually configure the top, left, right, bottom placement, is it recommended?

6
  • 2
    Can you show us the result? Commented Jul 25, 2013 at 2:30
  • you mean the image result? Commented Jul 25, 2013 at 2:32
  • 5
    I would not recommend doing that for all elements, as it will be a pain to render it across screen sizes. Use relatively placed elements and only use an absolute position where needed (ie. overlapping elements)
    – JanR
    Commented Jul 25, 2013 at 2:33
  • @AbieGiordano, AldiUnanto means (I think) a working example like jsfiddle, with html code.
    – Oriol
    Commented Jul 25, 2013 at 2:34
  • It depends on what are you trying to do. But in general, I would say it's a bad practice
    – Oriol
    Commented Jul 25, 2013 at 2:36

2 Answers 2

8

I think you don't have to put position: absolute for every element, it's not good. You can use absolute for only particular case. The fact is, position: absolute will put an element everywhere and it's may out of flow, and it won’t affect or be affected by any other element in the flow. You can learn more about positioning here :

  1. Course -> http://www.codecademy.com/courses/web-beginner-en-6merh
  2. Learn and sample -> http://alistapart.com/article/css-positioning-101
0
0

Using position: absolute depends on your html code and the parents of your element. But generally using 3 absolute position in a same time is not recommended! you can use both relative and absolute for more effective way for positioning. to understand position in CSS I suggest to watch below movie:

https://www.youtube.com/watch?v=jx5jmI0UlXU

Not the answer you're looking for? Browse other questions tagged or ask your own question.