我只是想向我的 php 画廊添加边框和背景颜色,但这些更改不适用于刷新。我也清除了缓存。
我试过: 添加“颜色:红色;”到段落和标题标签, 创建一个名为“border”的新类并将其添加到段落和标题标签中, 并编辑他们的 CSS 类都无济于事。
echo '<a href="#";">
<div style="background-image: url(img/gallery/'.$row["imgFullNameGallery"].');"></div>
<h3>'.$row["titleGallery"].'</h3>
<p>'.$row["descGallery"].'</p>
</a>';
.gallery-container a div {
width: 100%;
height: 205px;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
border-color:black;
border-width: 1px;
}
.gallery-container a h3 {
font-family: Catamaran;
font-size: 20px;
font-weight: 700;
color: #111;
padding-top: 16px;
line-height: 26px;
border-color:black;
border-width: 1px;
}
.gallery-container a p {
font-family: Catamaran;
font-size: 16px;
font-weight: 400;
color: #111;
padding-top: 4px;
line-height: 20px;
border-color:black;
border-width: 1px;
}
我希望添加边框,但实际输出什么都没有
最佳答案
首先你实际上不是echo
处理 css 字符串,所以它什么也不会发生。客户端没有收到,css
是浏览器穿插的东西。
但是,php echo
只给出浏览器文本,在您的情况下它假定为 html
所以你不能只把 css
没有将它包装在 <style>
中.
固定:
echo '<a href="#">
<div style="background-image: url(img/gallery/'.$row["imgFullNameGallery"].')"</div>
<h3>'.$row["titleGallery"].'</h3>
<p>'.$row["descGallery"].'</p>
</a>';
echo "<style>
.gallery-container a div {
width: 100%;
height: 205px;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
border-color:black;
border-width: 1px;
}
.gallery-container a h3 {
font-family: Catamaran;
font-size: 20px;
font-weight: 700;
color: #111;
padding-top: 16px;
line-height: 26px;
border-color:black;
border-width: 1px;
}
.gallery-container a p {
font-family: Catamaran;
font-size: 16px;
font-weight: 400;
color: #111;
padding-top: 4px;
line-height: 20px;
border-color:black;
border-width: 1px;
}
</style>"
如果 css
在不同的文件中,那么您需要确保使用 html
获取它.从您发布的代码中获取它可以像这样实现:
page_style.css
将是带有 css 的文件。
php代码:
echo '<a href="#">
<div style="background-image: url(img/gallery/'.$row["imgFullNameGallery"].')"</div>
<h3>'.$row["titleGallery"].'</h3>
<p>'.$row["descGallery"].'</p>
</a>
<link rel="stylesheet" type="text/css" href="page_style.css">
';
关于php - Css 更改不适用于 php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57314293/