移动端使用定位后位置空出来的问题及解决方法

HTML部分

<div class="gameDownload">
			<div class="publicTitle flex">
				<p>游戏下载</p>
				<p><a href="#">更多</a></p>
			</div>
			<div class="gameDownloadType">
				<p class="gameDownloadTypeColor">角色扮演</p>
				<p>动作冒险</p>
				<p>体育竞技</p>
				<p>经营策略</p>
				<p>角色扮演</p>
				<p>动作冒险</p>
				<p>体育竞技</p>
				<p>经营策略</p>
				<p>角色扮演</p>
			</div>
			<div class="gameDownloadListAll">
				<div class="gameDownloadContent gameDownloadShow">
					<div class="gameDownloadList">
						<div class="tuijianGameList">
							<div class="tuijianGameListLeft">
								<img src="/Images/hotGameTuijian2.png" alt="">
							</div>
							<div class="tuijianGameListRight">
								<div>
									<p>111崩坏三</p>
									<p>角色扮演 | 893.3MB</p>
									<p>为世界上所有的美好而战</p>
								</div>
								<a href="#">下载</a>
							</div>
						</div>
					</div>
					<div class="gameDownloadList">
						<div class="tuijianGameList">
							<div class="tuijianGameListLeft">
								<img src="/Images/hotGameTuijian2.png" alt="">
							</div>
							<div class="tuijianGameListRight">
								<div>
									<p>崩坏三</p>
									<p>角色扮演 | 893.3MB</p>
									<p>为世界上所有的美好而战</p>
								</div>
								<a href="#">下载</a>
							</div>
						</div>
					</div>
					<div class="gameDownloadList">
						<div class="tuijianGameList">
							<div class="tuijianGameListLeft">
								<img src="/Images/hotGameTuijian2.png" alt="">
							</div>
							<div class="tuijianGameListRight">
								<div>
									<p>崩坏三</p>
									<p>角色扮演 | 893.3MB</p>
									<p>为世界上所有的美好而战</p>
								</div>
								<a href="#">下载</a>
							</div>
						</div>
					</div>
					<div class="gameDownloadList">
						<div class="tuijianGameList">
							<div class="tuijianGameListLeft">
								<img src="/Images/hotGameTuijian2.png" alt="">
							</div>
							<div class="tuijianGameListRight">
								<div>
									<p>崩坏三</p>
									<p>角色扮演 | 893.3MB</p>
									<p>为世界上所有的美好而战</p>
								</div>
								<a href="#">下载</a>
							</div>
						</div>
					</div>
					<div class="gameDownloadList">
						<div class="tuijianGameList">
							<div class="tuijianGameListLeft">
								<img src="/Images/hotGameTuijian2.png" alt="">
							</div>
							<div class="tuijianGameListRight">
								<div>
									<p>崩坏三</p>
									<p>角色扮演 | 893.3MB</p>
									<p>为世界上所有的美好而战</p>
								</div>
								<a href="#">下载</a>
							</div>
						</div>
					</div>
				
					<div class="gameDownloadList">
						<div class="tuijianGameList">
							<div class="tuijianGameListLeft">
								<img src="/Images/hotGameTuijian2.png" alt="">
							</div>
							<div class="tuijianGameListRight">
								<div>
									<p>崩坏三</p>
									<p>角色扮演 | 893.3MB</p>
									<p>为世界上所有的美好而战</p>
								</div>
								<a href="#">下载</a>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

CSS部分

.gameDownload {
	height: 5rem;
}
.gameDownloadType {
	display: flex;
	flex-wrap: nowrap;
	justify-content: flex-start;
	align-items: center;
	overflow-x: scroll;
	margin-bottom: .22rem;
}
.gameDownloadType::-webkit-scrollbar {
	display: none;
}
.gameDownloadType p {
	flex-shrink: 0;
	font-size: .14rem;
	font-family: PingFang SC;
	font-weight: 400;
	color: #333333;
	margin-right: .3rem;
}
.gameDownloadTypeColor {
	font-size: .16rem;
	font-weight: bold !important;
	margin-right: .22rem !important;
}
.gameDownloadListAll {
	display: flex;
}
.gameDownloadContent  {
	flex-shrink: 0;
	display: none;
	flex-direction: column;
	flex-wrap: wrap;
	height: 4.25rem;
	overflow-x: scroll;
}
.gameDownloadContent::-webkit-scrollbar {
	display: none;
}
.gameDownloadList {
	flex-shrink: 0;
	width: 88%;
	margin-right: .2rem;
}
.gameDownloadShow {
	display: flex;
	flex-direction: column;
	flex-wrap: wrap;
	width: 100%;
	overflow-x: scroll;
}
.tuijianGameList {
	display: flex;
	justify-content: space-between;
	align-items: center;
	height: .7rem;
	margin-bottom: .15rem;
}
.tuijianGameListLeft {
	display: flex;
	width: .7rem;
	height: .7rem;
}
.tuijianGameListLeft img {
	width: .7rem;
	height: .7rem;
}
.tuijianGameListRight {
	flex: 1;
	display: flex;
	justify-content: space-between;
	align-items: center;
	height: .7rem;
	margin-left: .1rem;
}
.tuijianGameListRight div {
	height: .7rem;
}
.tuijianGameListRight div p:nth-child(1) {
	font-size: .14rem;
	font-family: PingFang SC;
	font-weight: 400;
	color: #333333;
	margin-top: .1rem;
}
.tuijianGameListRight div p:nth-child(2),.tuijianGameListRight div p:nth-child(3) {
	font-size: .1rem;
	font-family: PingFang SC;
	font-weight: 400;
	color: #999999;
	margin-top: .04rem;
}
.tuijianGameListRight a {
	display: flex;
	justify-content: center;
	align-items: center;
	width: .64rem;
	height: .27rem;
	font-size: .14rem;
	font-family: PingFang SC;
	font-weight: 400;
	color: #FFFFFF;
	background: #01ADB4;
	opacity: 1;
	border-radius: .14rem;
}

JavaScript部分
此处rem与px转换大小请查看此文章:rem与px的转换.

window.onload = function(){
		changeHeight();
	}
	 function changeHeight(){
		var width = document.body.clientWidth;
        var gameDownloadListAll = document.querySelector(".gameDownload .gameDownloadListAll");
        var gameDownloadShow = document.querySelector(".gameDownload .gameDownloadShow");
        gameDownloadListAll.style.height = (gameDownloadShow.offsetHeight/100/(width/375))+'rem';
		console.log(gameDownloadListAll.style.height);
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值