0

i really need some help with this:

Click me for example

i have a div container #green (green border) with a bg image. the div is on 100% width and the bg image with css3's -cover-. In this div is another div #red which has a position absolute and right value. i want force the #red div to have always the same distance between a motive of the bg image. means if im scaling the browser window the gap should always be the same. my try was to divide the #red { right: 25px } css by $(window).width() and use this factor for

var factor = 0,253;
var width = $(window).width()*factor;

('#red').css('right', width);

but it does not work. hope you get my point, and every help would be much appreciated :)

1
  • 1
    I guess being an architect didn't work out for you, huh? Commented Feb 16, 2013 at 19:57

2 Answers 2

2

Use media queries:

@media (min-width:500px) { … }
Sign up to request clarification or add additional context in comments.

5 Comments

See this tutorial to see how to use it
thanks, but really, whats wrong with my method to do it? i mean i dont want it responsive on resize. just when the site loads... what am i doing wrong?
Media queries work both ways (which is how you should want it to be). If you want it to only work on load then you'll be limited to a JavaScript only solution.
yeah but thats the point! its okay to use js only, but look at my example, do i have a logical fault?
okay it works with lefti dont know why, but it does! thank you anyway for your effort :)
0

var factor = 0,253 is invalid syntax

SHould be

var factor = 0.253;

Use a browser console to check errors, this would pop right out

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.