正如标题所说,我想要实现的目标(只有 2 个分辨率,最小/最大 767px)
我可以实现其中一个或另一个……但不能两者兼而有之。让文本 div 具有绝对位置,使图像具有
transform: translateX(50%)
的弹性是我最好的方法,但它似乎不正确。
我将简化代码以便更好地阅读。
@media (max-width: 767px) {
.flex-md-row-reverse {
flex-direction: column-reverse !important;
}
.order-md-1 {
order: 2;
}
.order-md-2 {
order: 1;
}
}
<html>
<head>
<!--Load bootstrap before custom css-->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<!-- hero -->
<div class="container">
<div class="row hero flex-md-row-reverse">
<div class="hero-text col-md-6 order-md-1" >
MY TEXT
</div>
<div class="hero-img col-md-6 order-md-2">
<img src="https://placehold.co/200x200">
</div>
</div>
</div>
</body>
</html>
请更改
flex-direction: column-reverse !important;
到
flex-direction: row-reverse !important