Martin Dawson
Martin Dawson

Reputation: 7656

Changing width of div is moving element left

Hover over the volume icon in the jsfiddle and you can see that it moves the mute left.

How can I keep the icon in place and just expand the volume bar to the right?

I know I can change the min-width on the progress bar but I don't want to do this.

Preferably I don't want to change the css on any other divs apart from the volume controls and children

http://jsfiddle.net/denWG/65/

Html:

<div class="jp-sleek jp-jplayer jp-audio">
  <div class="jp-gui">
    <div class="jp-controls jp-icon-controls">
      <button class="jp-repeat"><i class="fa fa-repeat"></i></button>
      <div class="jp-progress">

      </div>
      <div class="jp-volume-controls">
        <button class="jp-mute"><i class="fa fa-volume-off"></i></button>
        <div class="jp-volume-bar">
        </div>
      </div>
      <button class="jp-full-screen"><i class="fa fa-expand"></i></button>
    </div>
  </div>
</div>

Relevant css:

.jp-volume-bar {
  height: 6px;
  width: 0;
  background-color: #a1c1f4;
  cursor: pointer;
  border-radius: 1px;
  transition-duration: 0.3s;
}

.jp-volume-controls:hover .jp-volume-bar {
  width: 100px;
  transition-duration: 0.3s;
}

Upvotes: 0

Views: 1666

Answers (1)

Stickers
Stickers

Reputation: 78686

You can set .jp-progress { flex: 0 0 240px; } rather than width.

.jp-jplayer {
  min-width: 900px;
}

.jp-jplayer .fa {
  font-size: 24px;
}

.jp-sleek .jp-gui {
  height: 42px;
  background-color: #e5e5e5;
  position: relative;
}

.jp-sleek .jp-gui .jp-icon-controls .jp-progress {
    background-color: green;
    height: 100%;
    flex: 0 0 240px;
    /* width: 600px; */
    /* min-width:240px; */
    position: relative;
}

.jp-sleek .jp-gui .jp-controls {
  height: 100%;
  position: relative;
  margin: 0 auto;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  width: 50%;
}

.jp-sleek .jp-gui .jp-controls .jp-volume-controls {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
}

.jp-sleek .jp-gui .jp-icon-controls button {
  min-width: 42px;
}

.jp-sleek .jp-gui .jp-controls button {
  color: #000;
  padding: 0;
  border: none;
  background-color: transparent;
}

.jp-sleek .jp-gui .jp-mute {
  height: 100%;
}

.jp-volume-bar {
  height: 6px;
  width: 0;
  background-color: #a1c1f4;
  cursor: pointer;
  border-radius: 1px;
  transition-duration: 0.3s;
}

.jp-volume-controls:hover .jp-volume-bar {
  width: 100px;
  transition-duration: 0.3s;
}
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

<div class="jp-sleek jp-jplayer jp-audio">
  <div class="jp-gui">
    <div class="jp-controls jp-icon-controls">
      <button class="jp-repeat"><i class="fa fa-repeat"></i></button>
      <div class="jp-progress">
        
      </div>
      <div class="jp-volume-controls">
        <button class="jp-mute"><i class="fa fa-volume-off"></i></button>
        <div class="jp-volume-bar">
        </div>
      </div>
      <button class="jp-full-screen"><i class="fa fa-expand"></i></button>
    </div>
  </div>
</div>

Upvotes: 1

Related Questions