【发布时间】:2022-01-03 16:52:59
【问题描述】:
我创建了一个我想在 wordpress 中使用的自定义 html CSS 代码 该代码在我的本地服务器上运行良好,但是当我将其推送到自定义 html 块时,它的工作方式就不一样了。 我使用flatsome主题 我的html代码是
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<!-- <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Work+Sans:wght@100;200;300;400;500;600&display=swap" rel="stylesheet"> -->
</head>
<body>
<div class="empty-space"></div>
<h3 class="title">Limited only by imagination</h3>
<div class="main-down-div">
<div class="main-div">
<div class="scroll-div">
<div class="content-container">
<div class="content">
<h4 class="sub-title">Taste The Freshness Of Herbs</h4>
<div class="content-images">
<img src="Lemon-Balm.png">
<img src="Lemon-Balm.png">
<img src="Lemon-Balm.png">
<img src="Lemon-Balm.png">
</div>
</div>
</div>
<div class="content-container">
<div class="content">
<h4 class="sub-title">Grow Your Own Edibles</h4>
<div class="content-images">
<img src="Spinach.png">
<img src="Strawberries.png">
<img src="Sunflower.png">
<img src="Thyme.png">
</div>
</div>
</div>
<div class="content-container">
<div class="content">
<h4 class="sub-title">Eat Healthy Microgreens</h4>
<div class="content-images">
<img src="Spinach.png">
<img src="Strawberries.png">
<img src="Sunflower.png">
<img src="Thyme.png">
</div>
</div>
</div>
<div class="content-container">
<div class="content">
<h4 class="sub-title">Liven Up Your Space</h4>
<div class="content-images">
<img src="Spinach.png">
<img src="Strawberries.png">
<img src="Sunflower.png">
<img src="Thyme.png">
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
CSS 代码
body{
font-family: 'Work Sans', sans-serif;
background-color: rgb(237, 237, 237);
}
.main-div{
background-color: rgb(237, 237, 237);
position: relative;
}
.title{
text-align: center;
}
.sub-title{
text-align: center;
font-size: 1.6vw;
font-weight: 500;
color: #404040;
}
.content-container{
width: 80%;
margin: auto;
}
.content{
margin: 0 0 10%;
}
.content-images{
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.content-images img{
width: 15%;
}
.scroll-div::-webkit-scrollbar {
display: none;
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}
.main-div::after{
content: '';
height: 125px;
top: 0;
right: 0;
left: 0;
position: absolute;
background: linear-gradient(to bottom, rgba(237, 237, 237, 1) 0%, rgba(237, 237, 237, 0) 100%);
}
.main-down-div{
position: relative;
}
.main-down-div::after{
content: '';
height: 100px;
bottom: 0;
right: 0;
left: 0;
position: absolute;
background: linear-gradient(to top, rgba(237, 237, 237, 1) 0%, rgba(237, 237, 237, 0) 100%);
}
.scroll-div{
overflow-y: scroll;
height: 70%;
position: relative;
padding-top: 3%;
}
.empty-space{
height: 100px;
}
@media only screen and (max-width: 600px) {
.scroll-div{
padding-top: 10%;
padding-bottom: 20%;
}
.content-images img{
width: 50%;
}
.title{
font-size: 8vw;
}
.sub-title{
text-align: center;
font-size: 6vw;
}
.scroll-div{
height: 75%;
}
.empty-space{
height: 0px;
}
}
当我将此代码放在 wordpress 上的自定义 html 块中时 overflow-y: scroll; 不适用于 .scroll-div 我也尝试过使用 overflow-y: scroll !important; 但它没有帮助 我相信有些东西没有阻止我的代码
this is how my code looks on my local server
this is how my output is when I add this code to a custom block on wordpress
【问题讨论】: