代码如下,移动端的效果是input没有左边框。
<!DOCTYPE html>
<html lang="en">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8">
<title>色盲测试</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
html,body{
width: 100%;
height: 100%;
}
.container {
width: 100%;
height: 100%;
background-color: skyblue;
}
.container .test {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.container .test .answer-box {
width: auto;
position: absolute;
left: 50%;
transform: translateX(-50%);
}
.container .test .answer-box input{
box-sizing: border-box;
width: 70vw;
height: 10vw;
}
</style>
</head>
<body>
<div class="container">
<div class="test">
<div class="answer-box">
<input type="text" class="answer">
<button class="submit">确认</button>
<span class="score">0</span>
</div>
</div>
</div>
<script src="js/jquery.min.js"></script>
<script type="text/javascript">
</script>
</body>
</html>
但是把父盒子宽度设置大一点又能看到了,而默认的auto却不行。
我试过去掉父盒子定位,但效果还是那样。
你要重新赋值