繁体   English   中英

将响应式背景图像添加到除法类引导程序

[英]Add a responsive background image to a division class bootstrap

我必须在图像中使用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%;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM