2

I am trying to move the box by giving CSS selector for <div> a relative position attribute and some distance from left and top edge. Problem is it's not working.

Selector is clearly working because if I uncomment visibility attribute, the image is hidden. What's wrong here?

HTML:

<body>
  <div id="test_logo">
    <img src="http://uselessproducts.weebly.com/uploads/5/2/5/5/5255421/_6517253_orig.jpg" height="100" width="100"/>
    <span id="test_logo_title">test</span>
  </div>
</body>

CSS:

* { margin:0px; padding:0px; }

html {
    font-family: Verdana, "Lucida Sans Unicode", Arial;
    font-size: 9px;
}

body {
    margin: 9px 0 0;
    background-color: #f37062;
    font-size: 100%;
}

#test_logo {
    /*visibility: hidden;*/
    position: relative;
    left: 100 px;
    top: 200 px;
}

jsFiddle link

5
  • Thank you for posting the relevant code. Please do so every time you ask a question. Commented Oct 24, 2012 at 18:00
  • As an aside, zeroing out margin and padding on everything by using the universal selector (*) is pretty heavy handed. You may want to rethink that. Commented Oct 24, 2012 at 18:03
  • @steveax, good point. I will take that out. Commented Oct 24, 2012 at 18:04
  • 1
    @steveax : not heavy handed, if done with intent and understanding of the implications. Personally, I prefer using some tested normalization css specs, such as the one used by html5boilerplate.com ... it can really smooth things out when trying to make things work well cross-browser. Commented Oct 24, 2012 at 18:27
  • 1
    @mori57 given the question title ("Beginners...") I thought it may have been done without understanding the implications. I'm a big fan of normalize.css (which HTML5 Boilerplate uses) but note that normalize.css doesn't employ the universal selector. Commented Oct 25, 2012 at 20:14

3 Answers 3

6

You just need to remove the spaces before px:

#test_logo {
    position: relative;
    left: 100px;
    top: 200px;
}
Sign up to request clarification or add additional context in comments.

Comments

2

Take the spaces out of the left: and top: specs in #test_logo, and you should be right as rain.

2 Comments

Wow, that was simple. Actually I just needed to delete space between 100 and px. Thanks.
Yeah, that's what I was trying to get at, but Michal spelled it out better for you. Glad that fixed your issue!
0

Here is the modified CSS, I think this should fix your problem, you can adjust the padding of the #logo to meet your space needs from the top and sides.

* {margin:0px; padding:0px;}

html{
    font-family: Verdana, "Lucida Sans Unicode", Arial;
    font-size: 9px;
}

body{
    margin: 0 auto;
    background-color: #a37062;
    font-size: 100%;
}


#logo{ 
    padding: 5px;
 }​

Heres the link to my fiddle http://jsfiddle.net/r9x5A/3/

But as the others stated, the problem you're having is the space between the numbers and 'px' in your css.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.