相关疑难解决方法(0)

是否可以在CSS中设置img标记的src属性的等价物?

是否可以src在CSS中设置属性值?目前,我正在做的是:

<img src="pathTo/myImage.jpg"/>
Run Code Online (Sandbox Code Playgroud)

我希望它是这样的

<img class="myClass" />
Run Code Online (Sandbox Code Playgroud)
.myClass {
    some-src-property: url("pathTo/myImage.jpg");
Run Code Online (Sandbox Code Playgroud)

我想这样做而不使用CSS中的backgroundbackground-image:属性.

html css image

504
推荐指数
9
解决办法
54万
查看次数

HTML5shiv vs Dean Edwards IE7-js vs Modernizr - 可以选择哪个?

我正在寻找建立我的第一个HTML5网站,并一直在寻找与IE合作.

有html5shiv,Dean Edwards ie7-js然后是Modernizr.这些都大致相同吗?我对哪条路线感到困惑.

html5 modernizr

113
推荐指数
3
解决办法
3万
查看次数

PNG背景图片未在IE 8中显示<使用html5?

我有以下HTML代码:

<section class="first-content-top">
    <img src="images/img-diner.png" />
    <h1>Menu</h1>
</section>
<section class="first-content-middle">
         <article class="menu">
     </article>
</section>
<section class="first-content-bottom"></section>
Run Code Online (Sandbox Code Playgroud)

使用以下类型的css:

.first-content-middle 
{
    background: url("images/bg-black.png") repeat;
    margin: 0 0 0 37px;
    padding: 0 20px;
    width: 595px;
}
Run Code Online (Sandbox Code Playgroud)

但在IE8中,我仍然看不到背景图像,就像我在IE9或firefox中看到的那样:

这是IE8的图片:

这是IE8的图片

这是一张firefox的图片,应该如何:

这是一张firefox的图片,它应该如何

我尝试了以下解决方案:

为了防止这个问题,我将以下html5shiv代码添加到页面的头部:

<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
Run Code Online (Sandbox Code Playgroud)

在firebug中,我检查以确保section元素具有display:block;属性集.

编辑:将heightcss属性添加到该部分可修复背景问题.但截面高度是可变的.那么我该如何解决这个问题呢?

有什么建议?

css html5 internet-explorer internet-explorer-8

2
推荐指数
1
解决办法
1万
查看次数