gpt4 book ai didi

javascript - NodeJS+Bootstrap+CSS : home buildup thumbnail gallery add white background to images

转载 作者:行者123 更新时间:2023-11-28 03:16:48 24 4
gpt4 key购买 nike

我有一个名为 mainContainer 的容器。在这个容器中,我想创建一个缩略图库。不幸的是,当我修改我的 CSS 时,我遇到了一些问题,我有一些白色背景颜色而不是我的 mainContainer 的背景颜色。

这是结果页面:thumbnail gallery with unexpected white background这是我页面的代码。

<html lang='fr'>
<head>
<% include includes/head-global %>
<% include includes/head-bootstrap %>
</head>
<body onload="buildUpPage()">
<div class = "container mainContainer" id = "mainContainer">
<div class="row" id="galleryTargets"> <!-- Row : thumbnail -->
</div>
</body>

<% include tools/thumbnail %>
<script>
function buildUpPage() {
var universData = <%- universData %>
createThumbnail(universData.targets, "galleryTargets", "/" + univers.name + "/")
}
</script>

为函数 createThumbnail 表达 JS 代码:

<script>
function addOneCaptionToContainer (item, containerDOM, baseImgTargetUrl) {
var thumbnail = document.createElement("div")
thumbnail.setAttribute("class", "thumbnail col-xs-4")

var ref = document.createElement("a")
ref.setAttribute("href", baseImgTargetUrl + item.name)
ref.setAttribute("class", "thumbnail")
thumbnail.appendChild(ref)

var img = document.createElement("img")
img.setAttribute("src", "/"+item.backgroundImage)
img.setAttribute("class", "imgThumbnails")
ref.appendChild(img)

document.getElementById(containerDOM).appendChild(thumbnail)
}
function createThumbnail(itemsList, containerDOM, baseImgTargetUrl) {
for (let u of itemsList) {
addOneCaptionToContainer(u, containerDOM, baseImgTargetUrl)
}

}
</script>

现在是 CSS 部分:

.mainContainer{
background-color: #A6A4AA;
}
.imgThumbnails {
/*for the thumbnails in the gallery */
margin: 0px;
border-style:solid;
border-width: medium;
border-color: #2C3756;
border-radius: 10px;
}

我将不胜感激。我必须怎么做才能去除这些白色背景颜色?


继承似乎会导致问题:参见 Properties not taken into account

最佳答案

您必须移除填充,否则如果您将background-color 设置为透明,将会出现空白。

.thumbnail{
padding: 0;
}

关于javascript - NodeJS+Bootstrap+CSS : home buildup thumbnail gallery add white background to images,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45430751/

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