У меня есть видеоконтейнер. Когда видео не воспроизводится, мне нужны три вещи:
Я пытался сдвинуть значки по углам с помощью align-self: flex-start и align-self: flex-end, но они не собираются по углам. В то же время я хочу, чтобы значок видео находился в центре поля.
Пока у меня это:
Мой СКСС:
.video-container {
width: 270px;
height: 202px;
border: 1px solid #cececc;
background-color: $grey-light;
padding: 15px;
margin: 20px;
display: flex;
align-items: center;
justify-content: center;
.top-left {
align-self: flex-start;
}
.bottom-right {
align-self: flex-end;
}
}
HTML:
<div class='video-container' id='remote-media' data-target='video.remoteContainer'>
<span class='top-left'>
<%= concept(Avatar::Cell,@meeting.invitee_id,current_user: current_user ) %>
</span>
<i class = "fa fa-video fa-3x"></i>
<span class='video-expand bottom-right'>
<i class = "far fa-expand-arrows-alt fa-2x" data-target='video.expand' data-action='click->video#expand'></i>
<i class = "far fa-compress-alt fa-2x display-none" data-target='video.contract' data-action='click->video#contract'></i>
</span>
</div>






вы можете добиться этого с помощью позиционирования css
Пожалуйста, проверьте следующую скрипку
.topLeft, .bottomRight{
position:absolute;
}
Теперь используется обычный CSS, и вы можете преобразовать его в свой SCSS.
.video-container {
width: 270px;
height: 202px;
border: 1px solid #cececc;
background-color: $grey-light;
padding: 15px;
margin: 20px;
display: flex;
align-items: center;
justify-content: center;
position: relative;
.top-left {
align-self: flex-start;
position: absolute;
top: 0px;
left: 0px;
}
.bottom-right {
align-self: flex-end;
position: absolute;
bottom: 0px;
right: 0px;
}
}Использование 'align-self' не может быть исправлено с позицией. Итак, попробуйте добавить относительное и абсолютное положение, чтобы решить их. Обратитесь к приведенному выше коду.
что я сделал
flex-direction вашего #video-container на columnjustify-content:space-between; объект в свой #video-container
3.используется align-selfсвойство для выравнивания дочерних элементов по разным местамэто работает нормально.
#video-container{
width:200px;
height:200px;
border:1px solid #000;
display:flex;
flex-direction:column;
justify-content:space-between;
}
#video-container>span{
border:1px solid #000;
width:50px;
height:50px;
}
.center{
align-self:center;
}
.bottom-right{
float:right;
align-self:flex-end;
}<div id = "video-container">
<span class = "top-left"></span>
<span class = "center"></span>
<span class = "bottom-right"></span>
</div>