使用CSS Grid系统,我有两列;第一列是40%,第二列是60%,使用grid-template-column。第一列是文本,第二列是img;如何使两列的高度相同?
.container
{
max-width: 1130px;
margin: 0 auto;
}
section
{
padding: 30px;
}
#sec-1
{
padding: 0;
}
.sec-1 img
{
width: 100%;
display: block;
}
#sec-1 .wrapper
{
padding: 50px;
background-image: linear-gradient(to bottom right, #a454fd, #2b05df);
color: white;
}
section[id^="sec"] h1
{
font-size: 34px;
font-weight: 900;
}
#sec-1 a
{
text-decoration: none;
color: white;
border: 1px solid white;
padding: 15px 30px;
border-radius: 25px;
margin: 50px auto;
display: block;
width: 115px;
}
#sec-1 a:hover
{
color: #0000cc;
cursor: pointer;
}
/* Small devices (portrait tablets and large phones, 600px and up) */
@media only screen and (min-width: 600px) {
}
/* Medium devices (landscape tablets, 768px and up) */
@media only screen and (min-width: 768px) {
}
/* Large devices (laptops/desktops, 992px and up) */
@media only screen and (min-width: 992px) {
#sec-1
{
display: grid;
grid-template-columns: 40% 60%;
}
}
个字符
2条答案
按热度按时间1tuwyuhd1#
考虑将
height: 100%
应用于<img>
元素:个字符
o4hqfura2#
根据提供的代码,为了实现所需的使网格页面中的内容列和图像列的高度相同的功能,可以使用以下CSS代码:
字符串