How does css3 select the previous element

div displays the file name, and x is the I tag. Now when the mouse is over I, I need to modify the background color of div, but there is no way to select the previous element,
, or can I select the first child element div in the parent div

Mar.11,2021

css there is no way to get the previous element, but you can get the following element

.
/**/
i+.ant-upload-list-item-info{}
/**/
i~.ant-upload-list-item-info{}

No, CSS is unidirectional.

but here you can consider putting the two elements together so that it is convenient for you to write CSS.


css can't figure out what to do. Do you see if you can try jQuery?

<script>
    $('.anticon-across').hover(function(){
        $(this).parent().find('.ant-upload-list-item-info').css('background','red')
    },function(){
        $(this).parent().find('.ant-upload-list-item-info').css('background','transparent')
    })
</script>

Is

a left and right floating structure?
if so, change the position of the div and I circled in your red line, and then use

.action:hover + .ant-upload-list-item-info {
    background: skyblue;
}

not yet. Adjust the position or use js to control


write the div tag after the I tag
if you ask not to change the html, you can't do it

.
Menu