gpt4 book ai didi

javascript - 将响应式背景图像添加到部门类 Bootstrap

转载 作者:行者123 更新时间:2023-11-28 17:54:01 24 4
gpt4 key购买 nike

我必须在图像中使用 javascript 函数。因此我想将图像添加为分区类中的背景图像。我希望它像 <img> 一样具有响应性和可扩展性。我使用的标签。如何实现?

最佳答案

CSS3 background-size 可以在这里使用。

background-size: [auto|percentage|units - for width] [auto|percentage|units - for height];

例如:

.bg{
/*will stretch the element's background to its full width (saving proportions of the picture - so it may be cut vertically or not fill the entire height):*/
background-size:100% auto;

/*will stretch the element's background to its full height (it may be cut - this time - horizontally or not fill the entire width):*/
background-size:auto 100%;

/* the background will be forced to the 50% of the el's width and 40% of its height respectively: */
background-size:50% 40%;
}

关于javascript - 将响应式背景图像添加到部门类 Bootstrap ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21643575/

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