gpt4 book ai didi

html - CSS 边框、不需要的间隙和子像素渲染问题

转载 作者:行者123 更新时间:2023-12-05 02:28:58 26 4
gpt4 key购买 nike

我正在为我的个人网站设计一个博文预览磁贴。无论我尝试做什么,图像与其底部边框之间始终存在间隙,或者图像与容器边框之间始终存在间隙。它出现在移动设备上、缩放时和缩放时。这是一个非常简单的设计,我快要疯了,不知道如何让它工作。我知道这与子像素渲染问题有关。请帮我!我要么希望间隙消失,要么呈现为与边框相同的颜色,这样它看起来就不会卡顿。

body {
background: rgba(255, 225, 172, 1);
display: grid;
grid-template-rows: [row-start] 1fr [row-end row2-start] 6fr [row2-end row3-start] 1fr [row3-end];
grid-template-columns: [col-start] 1fr [col-end];
row-gap: 60px;
padding-left: 120px;
padding-right: 120px;
}

.blog_preview_container {
grid-row: 2;
grid-column: 1;
height: 354px !important;
display: flex;
flex-flow: row wrap;
justify-content: space-between;
}

.blog_preview_titlecard {
height: 352px;
width: 272px;
}

.blog_tile {
height: 340px !important;
width: 240px !important;
margin: 1px;
background-color: white;
border: 6px solid black;
box-shadow: 4px 4px 6px rgba(0, 0, 0, 0.65);
color: white;
display: inline;
overflow: hidden;
cursor: pointer;
transform: scale(1);
}

.blog_tile:hover {
transform: scale(1.05);
}

.blog_tile_image {
display: block;
border-bottom: 6px solid black;
}

.blog_tile_text {
height: 138px;
font-family: 'nunito', sans-serif;
font-size: 1rem;
font-weight: 900;
margin: 0;
padding: 16px;
}
<body>
<div class="blog_preview_container">
<img class="blog_preview_titlecard" src="https://example.com/titlecard_location">
<div class="blog_tile">
<img class="blog_tile_image" src="https://example.com/img_location">
<p class="blog_tile_text">Text Goes Here</p>
</div>
</div>
</body>

最佳答案

我试过这张图片,看来您只需更改 blog_tile 的背景颜色即可,因为黑色会补救它。

body {
background: rgba(255, 225, 172, 1);
display: grid;
grid-template-rows: [row-start] 1fr [row-end row2-start] 6fr [row2-end row3-start] 1fr [row3-end];
grid-template-columns: [col-start] 1fr [col-end];
row-gap: 60px;
padding-left: 120px;
padding-right: 120px;
}

.blog_preview_container {
grid-row: 2;
grid-column: 1;
height: 354px !important;
display: flex;
flex-flow: row wrap;
justify-content: space-between;
}

.blog_preview_titlecard {
height: 352px;
width: 272px;
}

.blog_tile {
height: 340px !important;
width: 240px !important;
margin: 0px;
border: 6px solid black;
box-shadow: 4px 4px 6px rgba(0, 0, 0, 0.65);
color: white;
background-color: white;

}

.blog_tile:hover {
transform: scale(1.05);
margin-top: 0px;
background-color: black;
}

.blog_tile img {
height: 340px;
width: 242px;
object-fit: cover;
margin: -1px 0px 0px -1px;

}

.blog_tile_image {
display: block;
border-bottom: 6px solid black;
}

.blog_tile_text {
height: 138px;
font-family: 'nunito', sans-serif;
font-size: 1rem;
font-weight: 900;
margin: 0;
padding: 16px;
color: white;
}
<body>
<div class="blog_preview_container">
<img class="blog_preview_titlecard" src="https://media.istockphoto.com/photos/picturesque-morning-in-plitvice-national-park-colorful-spring-scene-picture-id1093110112?k=20&m=1093110112&s=612x612&w=0&h=3OhKOpvzOSJgwThQmGhshfOnZTvMExZX2R91jNNStBY=">
<div class="blog_tile">
<img class="blog_tile_image" src="https://media.istockphoto.com/photos/picturesque-morning-in-plitvice-national-park-colorful-spring-scene-picture-id1093110112?k=20&m=1093110112&s=612x612&w=0&h=3OhKOpvzOSJgwThQmGhshfOnZTvMExZX2R91jNNStBY=">
<p class="blog_tile_text">Text Goes Here</p>
</div>
</div>
</body>

关于html - CSS 边框、不需要的间隙和子像素渲染问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72401182/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com