在以下代码中
<style>
/* Set height to 100% for body and html to enable the background image to cover the whole page: */
body, html {
height: 100%
}
body {
background-image: url('/assets/root/001.png');
// background-size: contain;
// background-position: center;
我的页面上有一个粘性的页脚,但是如果我启用了确保SVG图像在悬停时改变颜色的javascript,SVG文件就不会在chrome中显示。删除javascript会导致Chrome很好地加载图像。
我无法在jsfiddle中重新创建效果,但代码如下:
这是javascript代码:
$( document ).ready( function () {
$( 'img[src$=".svg"]' ).each( function () {
var $img = jQuery( this );
var imgURL = $img
我们能用javascript做到这一点吗?
假设我们有一个x*y px div
(width=x和hight=y)
和用户上传任何大小的图像,我想找到一种方法,这个图像不会在容器中变形。我有一个senario,但我不确定除了css之外,还可以通过javascript或jquery实现。您可以在下面看到我的senario,但我不知道如何才能用javascript正确地编写
var ContainerWidth=document.getElementById("Container").width;
var ContainerHight=document.getElementById