Ich habe einen Fortschrittsbalken, der zwei Kinder (Teile) hat. Wenn jedes dieser Kinder schwebt, ändert sich die Gesamthöhe des Fortschritts und seiner Kinder. Ich habe es geschafft, die ersten Kinder mit der next sibling selector
zu lösen, aber ich kann keine Lösung für die zweiten Kinder finden (der gelbe Teil). Bis jetzt habe ich das mit jQuery gelöst, aber ich möchte das in reinem CSS tun.CSS wählen vorherige Geschwister
Geige: https://jsfiddle.net/zfh263r6/5/
$('#start').on({
mouseenter: function() {
\t //$(this).css('height', '4px');
//$('progress').css('height', '4px');
},
mouseleave: function() {
\t //$(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;
\t 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>
CSS kann nicht vorherigen Geschwister wählen. – undefined
Gibt es eine andere Möglichkeit, dies nur mit CSS zu erreichen? @Vohuman –
Ich glaube nicht. Ich kann nur daran denken, die Hover-Höhe zu "beschleunigen" und zu "starten" und dann "progress_wrap" überlaufen zu lassen: versteckt und kürzer und mache * das * beim Hover. – Draco18s