Not sure about my CSS layout

I am working on a UI for my video elements, and am copying the YouTube layout. The markup for it is this:


<div class="video-control-bar">
  <div class="video-play-button"/>
  <div class="video-volume">
    <div class="video-volume-slider">
      <progress value="1.0" max="1.0"/>
      <input type="range" min="0.0" max="1" step="0.05" value="1.0"/>
    </div>
    <div class="video-volume-button"/>
  </div>
  <div class="video-timecode">
    <span class="video-timecode-current">00:00</span> / <span class="video-timecode-total">00:00</span>
  </div>
  <div class="video-maximize-button"/>
</div>

I’m using javascript to expand the volume element when you mouse over it. Here is a visual:

Currently all the elements within the control bar have absolute positioning, and I animate the width value for the volume div and the left value for the timecode. I think it’s kind of messy having to hard code the position for everything with CSS and JavaScript. Is there a better way to accomplish this?

Links are much more preferable. :slight_smile:

Well, I haven’t really got any hosting atm. This is the best I can do: Video test

Because it needs to be rendered on top. I suppose I could use z-index, but that seemed easier.


.video-control-bar {
	overflow:hidden; /* wrap floats */
	width:100%; /* trip haslayout, wrap floats IE */
}

.video-play-button,
.video-volume,
.video-volume-slider,
.video-volume-button,
.video-timecode {
	float:left;
}

.video-maximize-button {
	float:right;
}

.video-position {
	// needs no extra CSS, should fill gap between floats
}

Stack the ones on the left, max on the right, position fills the gap. SIMPLE. Methinks you’re diving too quickly for the APO. Let normal flow and floats do their job!

Silly question, but what’s with the valid XML that’s invalid in most user agents (the self closing DIV) - are you omitting code, or just saying to hell with EVERY version of IE? Also not sure what you need the twin span or paragraph tag for (as that’s not a paragraph).

If I have time I’ll code up an example once your attachment is approved.

I fail to understand your suggestion.

Here is the full markup


<div class="video-container">
  <video title="Tron (1982)" width="640" src="tron.webm"/>
  <div class="video-ui">
    <div class="video-title"/>
    <img class="video-watermark" src="html5-logo.svg"/>
    <div class="video-control-bar">
      <div class="video-play-button"/>
      <div class="video-volume">
        <div class="video-volume-slider">
          <progress value="1.0" max="1.0"/>
          <input type="range" min="0.0" max="1" step="0.05" value="1.0"/>
        </div>
        <div class="video-volume-button"/>
      </div>
      <div class="video-timecode">
        <p><span class="video-timecode-current">00:00</span> / <span class="video-timecode-total">00:00</span></p>
      </div>
      <div class="video-maximize-button"/>
      <div class="video-position">
        <progress value="0" max="1.0"/>
        <input type="range" min="0" max="1.0" step="0.005" value="0"/>
      </div>
    </div>
  </div>
</div>

Here is a picture of the whole player.

I am animating the position of video-control-bar with JS, to make it “pop up” when your mouse is over the video container. The layout and functionality is identical to YouTube’s if you need an example of how things should work.

I don’t think making this work is as simple as “float everything left.” :confused:

Instead of posting pictures, which don’t show up right away – could you post a link to live code? Snippets and images are useless as we don’t get the entire “picture”

Especially when we often have to wait HOURS to see pictures you put on your posts as attachments… but even when we see the pictures we’re stuck guessing which visual element you want is which element in the code… for example .video-position; is that the bit ABOVE the bar, in which case why is it source-order at the end of it?!?

Here is what it looks like with things set to float:

Not every version of IE. IE9 is smart enough to understand application/xhtml+xml. I’m saying to hell with all version of IE that are 8 and older.

I have the paragraph so I can vertically align the text to the middle of the bar, and the spans are so I can access the position of the video and the overall duration separately. They are also to theme the font color differently.

I’m wondering why you’re not just using floats – there’s nothing there that should need APO. It also feels element heavy with all the classes for nothing. Set .video-control-bar to overflow:hidden and width:100%; (giving IE haslayout), float everything left except .video-maximize-button – simple.

I tried inline-block, but then there was a gap between the play button and the volume that I couldn’t get rid of and the elements inside of the volume div are absolutely positioned themselves, so they then get screwed up.

why not use ‘display: inline-block’ ?
then you would only need to change the with

see:
display (CSS property)

note: does not work in IE7 but there is a simple hack for it just google it,