我在背景中有响应图像,在它上面我有矩形框。随着图像高度的降低,我需要降低高度。我可以使用@media查询实现它,但似乎我必须编写许多屏幕大小。有没有更好的解决方案可以在没有@media查询的情况下实现它,如果没有@media查询可以少写它。
HTML
<!DOCTYPE html>
<html>
<head>
<link data-require="bootstrap-css@3.3.6" data-semver="3.3.6" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.css" />
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 no-padding">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 no-padding backgroundImage">
<div class="graybox">
</div>
</div>
</div>
</div>
</body>
</html>
CSS
.backgroundImage
{
background-image: url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxQTEhUUExQVFhUXGBgaGBgYGBgXGhgaFxscGxcYGBwZHCggGh4lHBgXJDEhJSkrLi4uGB8zODMsNygtLisBCgoKDg0OFxAQGiwcHBwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLP/AABEIAJ8BPgMBIgACEQEDEQH/xAAaAAADAQEBAQAAAAAAAAAAAAACAwQFAQAG/8QAOxAAAQIEBAMFBwMEAgIDAAAAAQIRAAMhMQQSQVFhcfAFgZGhsQYTIsHR4fEUMkIVUmJyI6IWkjNDgv/EABcBAQEBAQAAAAAAAAAAAAAAAAABAgP/xAAcEQEBAQEAAgMAAAAAAAAAAAAAAREhAhIxQVH/2gAMAwEAAhEDEQA/ALzLD/t7w4v3x3GYdN3A61+kZRJglEnWMNG/pj/Fm3tFCcETv4jyiJEwixaCEw7mILl4QAC/jAzMNKSCVlQ2AqS9m1P2jPmTuNawpK1ZRfxi4rVk4ZFztrmFORtF3u0JS2gc2Yab36rHzapxJhonKf4vP6wRsYgyyxLFu+M3FSUguKE8XvAARyYiKjxQCzFgC3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Pxg/cpbhD2lMZy55IPwkhw+rcPKEGY4jRnyUu9iee0RAV1bxvG/G78M1KlRsbRxE0u1R0I0FEUdJItR4p/RJaidIXJ8iGVOUSmzF9Obg8adPBhdQKNxJ3N6fOHf08EAFvh6q8cXhBsS3IRPaVcMxeIBLULFqnViIqlW0SHAqE2Jpc8SIiRhlfEcpVzvX1+ggU4ZYBdKK6E1bmKcNdYW9RpTQMvw5a3UWsaFiDE0tFBfnTj9IQmQU2tzIrBy06MojcGMeW1qccMok328ooQCzP8ohkJL6736aNJCmvGdHA9j1vHiLb9WgiqOy0klrwULbCsBNlMH0fbwvGmrslaD8TA7O+wbzj2Lw+ZAPfATfqLOH+f0hMyWDw8PkHjgHX2irBYMrBOZm4QREqaLF7cu+rQpUylBt60+UBjnCmTVzXiBClzTarPbcliPIxQ1aq2Ap+e6OhRGg65wKas1457o3eActwHBGnD5VhfvCbt1uY9hpwsXMdJqW5mIpqFXt1ygZyiGZm8Oj9Y8mYDb0aCSsa90JQPvFLY2IYUan1hxkkiqomQtna3GOzZyqEOH5OYB6ENR78+jHlqa7typ9NtYZhMKZiv3s2lT1+IHtWV7vVyA+0VE8wg9W4UtCkVJc2tBYVBIre52rWGCRruKRFAUmjn115BopQDSp65wiWog7jZ211rFYVSrRBKlB063pFKpYyZnDu2X+XM7COZn0rHUij9eUKQohWUmjtXQceQif3xNCw5RWoUcm0TTCCaX+UWDmFSxbf02AilIHX3tEsuUcwrR418N2YuZommpPOzDhASHDZgwHe/l1vCEIrr1+Y1pXZ+RVdjryJA8omxUjKa20h9IhAU5H8aetYplINuXRjiZcEhmreG6oM4doBSfrBTVVB0NOvCDz+EIihWJOUJCgAzMEAE7h7+cQ4jRqDq0NJibFzSCGdz6kGp7gYBaH1NqesFm3JhUpdHfqzxOs6O3j8oD//2Q==');
background-repeat:no-repeat;
height: 800px;
width: 100%;
-webkit-background-size: cover;
-moz-background-size: 100% auto;
-o-background-size: cover;
background-size: 100% auto;
}
.graybox{
width: 80%;
background: BLACK;
display: inline-block;
margin-left: 10%;
margin-top: 106px;
height: 20%;
opacity: 0.5;
}
@media (max-width: 1240px) and (min-width:1100px){
.graybox{
height : 40%;
}
}
@media (max-width: 1139px) and (min-width:760px){
.graybox{
height : 30%;
}
}