如何针对不同的宽度和高度响应地调整元素

时间:2018-03-12 08:34:57

标签: html css responsive-design ionic2

下面是包含OK文本作为元素的屏幕截图以及左侧和右侧的其他2个元素。右侧和最后一个按钮。

.center-text {
	font-weight: bold;
	font-style: normal;
	text-align: center;
	font-size: 25px;
	line-height: 30px;
	letter-spacing: normal;
	opacity: 1.0;
	margin-top: 25% !important;
}
.lower-content {
	margin-bottom: 30px;
}
.group:before, .group:after {
	content: "";
	display: table;
}
.group:after {
	clear: both;
}
.group {
	clear: both;
 *zoom: 1;
}
.lower-content-left {
	float: left;
	margin: 0 1.5%;
	width: 63%;
}
.lower-content-right {
	float: right;
	margin: 0 1.5%;
	width: 30%;
}
.button-left {
	position: absolute;
	width: 140px;
	height: 140px;
	left: 100px !important;
	right: 0;
	bottom: 0;
	top: 620px;
}
.button-left>div {
	width: 100px;
	height: 100px;
}
.notification-button {
	margin-left: 15px;
	margin-top: 10px;
	zoom: 2.0;
}
.button-right {
	position: absolute;
	width: 140px;
	height: 140px;
	left: 250px;
	right: 20px;
	bottom: 0;
	top: 620px;
}
.button-right>div {
	width: 100px;
	height: 100px;
}
.heart-button {
	margin-left: 15px;
	margin-top: 10px;
	zoom: 2.0;
}
<div class="center-text">Ok</div> 

<div class="group">

<div class="lower-content-left">
  <div class="lower-left">click here</div>
  <div class="search-channels">Click
    <br>Here</div>
</div>

<div class="lower-content-right">
  <div class="lower-right">Otherwise Click here</div>
  <div class="qrCode">Click here
    <br>Also</div>
</div>

<div class="button-left">
  <div>
    <ion-icon name="notification" class="notification-button"></ion-icon>
  </div>
</div>

<div class="button-right">
  <div>
    <ion-icon name="heart" class="heart-button"></ion-icon>
  </div>
</div>

问题:当我更改屏幕宽度时,按钮会隐藏或不存在于当前位置,所有元素都相同。 我已经在截图中发布了。我只需要编辑我的CSS以使其响应截图。

enter image description here

1 个答案:

答案 0 :(得分:1)

尝试通过解决方案使用css。

示例:

@media (max-width: 300px) {
    .your-class {
        your:option; }
        }

@media (max-width: 600px) {
    .your-class {
        your:option; }
        }