【发布时间】:2020-04-28 18:13:16
【问题描述】:
我正在尝试处理父 div 中多个 div 的完全响应性,并且在网格视图中有多个类似类型的父 div,其值为 class="col-md-6"。我尝试减小图像宽度和字体大小,但没有任何事情发生。我希望它在我们减小屏幕尺寸时自动调整元素,保持值完全可见。我在下面的屏幕截图中分享了代码和问题。
CSS
.games-table{
padding: 30px;
}
.gameRow{
box-shadow: 0px 0px 6px 0px;
border-radius: 5px;
margin-left: 5px;
margin-right: 5px;
margin-bottom: 20px;
cursor: pointer;
}
.gameRow:hover{
box-shadow: 0px 0px 15px 0px;
}
.gameNo{
margin-bottom: 0px;
}
.gameNo, .imgBox, .courtBox{
text-align: center;
}
li{
list-style-type: none;
}
.imgteam1, .imgteam2{
width: 48px;
height:auto;
}
.gamenum-box{
background-color: #000066;
color: #ffffff;
}
.gamenum-box, .imgBox, .courtBox{
padding: 20px 20px;
}
.datetimeBox{
padding: 5px 5px;
}
.vs-span{
margin: 0px 10px;
}
th,td{
padding: 0px 10px;
}
th{
border-bottom: 1px solid #cccccc;
}
.datetimeBox{
color: #000000;
border-width: 3px;
border-style: solid;
border-image: linear-gradient(to top, #cccccc, rgba(0, 0, 0, 0) ) 1 100%;
background-image: linear-gradient(80deg, #f1f1f1 , white, #f1f1f1);
transform: skew(-10deg, 0deg);
}
table{
transform: skew(10deg, 0deg);
width: 100%;
}
#games{
z-index:0;
-webkit-transform: translateZ( 0 );
transform: translateZ( 0 );
-webkit-transition: -webkit-transform 0.6s ease-in-out;
transition: transform 0.6s ease-in-out;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.newDiv{
width:50%;
}
.gamenum-box, .courtBox {
width: 20%;
}
.datetimeBox{
width:30%;
}
.imgBox{
width:30%;
}
.gameVis{
display: none;
}
@media only screen and (max-width:600px){
.games-table{
padding:10px;
}
.newDiv{
width:100%;
}
.imgteam1, .imgteam2{
width: 27px;
}
.gamenum-box, .imgBox, .courtBox{
padding: 16px 1px;
}
th,td{
padding: 0px 1px;
}
}
@media only screen and (max-width:480px){
.games-table{
padding: 5px;
}
/* .gameNoVis{
display: none;
}
.gameVis{
display: block;
} */
.gamenum-box{
width: 13%;
}
.imgBox{
width: 32%;
}
.datetimeBox{
width: 40%;
}
.courtBox {
width: 15%;
}
}
HTML 代码
<div class="game-table">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="head mb-4">
<h2>Matches</h2>
</div>
</div>
</div>
<div class="row">
<!-- Start Games Section -->
<div class="col-xs-12 col-md-6 col-sm-12 col-lg-6">
<div id="games">
<div class="row gameRow">
<div class="gamenum-box col-md-2">
<p class="gameNo">GAME</p>
<p class="gameNo">1</p>
</div>
<div class="imgBox col-md-4">
<img src="../assets/images/games/team1.png" class="imgteam1">
<span class="vs-span">VS</span>
<img src="../assets/images/games/team2.png" class="imgteam2">
</div>
<div class="datetimeBox col-md-4">
<table>
<tr>
<th><b>Date</b></th>
<th><b>Time</b></th>
</tr>
<tr>
<td><b>12 Jan 2019</b></td>
<td><b>12:00PM</b></td>
</tr>
</table>
</div>
<div class="courtBox col-md-2">
<p class="gameNo">COURT</p>
<p class="gameNo">1</p>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-md-6 col-sm-12 col-lg-6">
<div id="games">
<div class="row gameRow">
<div class="gamenum-box col-md-2">
<p class="gameNo">GAME</p>
<p class="gameNo">1</p>
</div>
<div class="imgBox col-md-4">
<img src="../assets/images/games/team1.png" class="imgteam1">
<span class="vs-span">VS</span>
<img src="../assets/images/games/team2.png" class="imgteam2">
</div>
<div class="datetimeBox col-md-4">
<table>
<tr>
<th><b>Date</b></th>
<th><b>Time</b></th>
</tr>
<tr>
<td><b>12 Jan 2019</b></td>
<td><b>12:00PM</b></td>
</tr>
</table>
</div>
<div class="courtBox col-md-2">
<p class="gameNo">COURT</p>
<p class="gameNo">1</p>
</div>
</div>
</div>
</div>
<!-- End Games Section -->
</div>
</div>
</div>
截图
使用的实际图片
【问题讨论】:
-
我在代码片段中检查了您的代码,但是当您必须检查各种屏幕上的响应性时,它无法正常工作。我在自己的环境中检查了您的代码,您的网页看起来不错。我无法做出的唯一评估是您没有原始图像。我怀疑您的图像是问题所在,否则网格在响应性方面工作得很好。
-
您能否在您的图像中添加一个代码 sn-p,以便我们在有任何问题时进行调整?或者我不知道...分享你的图片。
-
@Mugé 我已经分享了问题帖子中的图片!请检查... 至于代码 sn-p,这是来自 Angular 8 代码的一个组件。
-
那么它对你有用吗?
-
是的。谢谢!我还创建了一个没有盒子高度的响应式设计,效果很好!
标签: html css bootstrap-4 responsive-design