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

标签 javascript html css twitter-bootstrap twitter-bootstrap-3

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

相关文章:

html - Outlook 中表格一侧的 1px 白色边框

html - 这可能与 Dreamweaver 中的正则表达式有关吗?

javascript - 如何在 jQuery 中的课后将课添加到 div?

java - 有没有办法将 css 样式类添加到 Java 字符串内联

javascript - React 修改显示的值而不改变输入表单的值

javascript - 在自定义 javascript 中创建类似 JQuery 的插件结构

jquery - Windows 7 浏览器忽略 DIV 高度 100%

javascript - 如何重命名对象并在 FabricJS 中渲染 Canvas ?

javascript - JSDoc 在文档中添加真实代码

jquery - 互联网浏览器 :hover state becomes sticky when the target DOM element is moved in the DOM