The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS css stretching/contracting element triggered by right element (unknown width)

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #35505

    ..first post here + vague title == hoping for a solution ;)
    I put up a sample at jsfiddle:

    I want to see if it is possible to make this work without setting a right margin value on the first/red element.

    The idea is that the red element is stretchable between a min and max width. The right element is sort of the trigger. When you make the window smaller you see what happens.
    Right now this “works” because I have set a right margin value on the red element that is about the total width of the green element (including margin etc.) – but I’m looking for a css way to have some right element of unknown size (could be a container of several depending on the browser width) that triggers the red element to get smaller when you narrow the window.

    I know my way with JS so I could calculate the width and dynamically set a right margin value; but I though it would be easy with just css (but I guess not, spend too much time on it already).

    It’s a bit like how gmail looks (in Firefox at least) where you have the search + button in the middle and the account name + settings on the right.. but the gmail html is like a gazillion div’s etc. (which I rather not dive into).


Viewing 1 post (of 1 total)
  • The forum ‘CSS’ is closed to new topics and replies.