<分区>
我有一个进度条,它有两个子项(部分)。每当这些 child 中的每一个被悬停时,进度的总高度及其 child 都会改变。我已经设法使用 next sibling selector
解决了第一个 child 的问题,但我找不到第二个 child (黄色部分)的解决方案。到目前为止,我已经使用 jQuery 解决了这个问题,但我想用纯 CSS 来解决这个问题。
fiddle :https://jsfiddle.net/zfh263r6/5/
$('#start').on({
mouseenter: function () {
//$(this).css('height', '4px');
//$( 'progress' ).css('height', '4px');
},
mouseleave: function () {
//$(this).css('height', '');
// $( 'progress' ).css('height', '');
}
});
#progress_wrap {
position: relative;
height: 4px; /*max height of progress*/
background: #f3f3f3;
}
progress {
appearance: none;
-moz-appearance: none;
-webkit-appearance: none;
width: 100%;
border:none;
height: 2px;
transition:all .25s ease-in;
cursor: pointer;
background-color: #fff;
position: absolute;
top: 0;
left: 0;
display: block;
}
progress:hover, progress:hover + #start {height: 4px}
progress[value] {
/* Reset the default appearance */
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
/* Get rid of default border in Firefox. */
border: none;
/* For IE10 */
color: #f8008c;
}
progress[value]::-webkit-progress-bar {
background-color: #fff;
border:none;
}
progress[value]::-webkit-progress-value {background:#f8008c}
progress::-ms-progress-value {background:#f8008c}
progress::-moz-progress-bar {background:#f8008c}
progress::-ms-fill {border: none}
#start {
height: 2px;
transition: all .25s ease-in;
cursor: pointer;
background-color: #ffe232;
position: absolute;
top: 0;
left: 0px;
width: 30px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="progress_wrap">
<progress min="0" max="1" value="0.66" id="progress"></progress>
<div id="start" style="display: inline-block; left: 50px;"></div>
</div>