簡體   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