在本文中,我们将给您介绍关于css–在鼠标上显示背景图像的详细内容,并且为您解答css中鼠标放上去显示的相关问题,此外,我们还将为您提供关于css–IE8上没有显示背景图像、css–不显示背景图像的元
在本文中,我们将给您介绍关于css – 在鼠标上显示背景图像的详细内容,并且为您解答css中鼠标放上去显示的相关问题,此外,我们还将为您提供关于css – IE8上没有显示背景图像、css – 不显示背景图像的元素、css – 使背景图像显示在一个空白的div元素中、css – 在Firefox中不显示背景图像的知识。
本文目录一览:- css – 在鼠标上显示背景图像(css中鼠标放上去显示)
- css – IE8上没有显示背景图像
- css – 不显示背景图像的元素
- css – 使背景图像显示在一个空白的div元素中
- css – 在Firefox中不显示背景图像
css – 在鼠标上显示背景图像(css中鼠标放上去显示)
<a href="#">Wardrobe</a> <a href="#">Wine</a> <a href="#">Coffee</a>
这是相关的CSS:
.home-block { background-color: #c2b89c; display: block; height: 180px; line-height:180px; text-align: center; font-size: 70px; color:#e2e2e2; text-shadow: 2px 2px 0 #444; margin-bottom: 20px; background-size: cover; background-position: center center; Box-shadow: 1px 1px 4px #111; }
我的结果现在看起来像这样:
没关系,但我真正想要的是具有纯色的块,并且仅在悬停时显示图像.像这样:
请记住,我正在使用响应式设计,因此块在不同的屏幕尺寸上将具有不同的大小和宽高比.这就是我使用background-size:cover的原因.这也适用于CMS系统,因此我希望图像和颜色在HTML中内嵌设置,因此可以轻松编辑,并且可以添加更多块.
所以我基本上需要一个没有绝对定位元素的清洁解决方案(因为它们在没有固定宽度时会断裂)来实现这一点.
我试过的是这个:
.home-block { background: none; } .home-block:hover { background: inherit }
但没有成功.我正准备使用一些jQuery来修复所有这些,但我很快就想检查是否没有纯CSS方法来实现这一点.
解决方法
.home-block { ... background-position: 1000px 1000px; // background-image is there but not visible } .home-block:hover { background-position: center center !important; // make it visible }
http://jsfiddle.net/h2Jbg/
因此,对于正常状态,您将看不到背景图像,但会看到背景颜色.在悬停时,您将图像移回.
css – IE8上没有显示背景图像
该网站是(经过重新设计,因此不再相关.它使用HTML5元素,但它们未被声明为块,IE并不认为它们应该是.)
页脚上的渐变在非IE浏览器中看起来很棒,但无法在IE 7,8和IE9开发预览中显示.
有任何想法吗?
解决方法
footer { display:block; }
这在FF3.6下为我修复了,我假设它也会在IE中修复它 – < footer>的默认显示样式无论浏览器如何,内联都不适合背景.对它应用块会将它更像div.
您还需要小心使用HTML 5.不确定它在所有浏览器中的支持程度.您可能需要考虑< div id =“footer”><! - 页脚的内容 - >< / div>并在CSS中通过id应用样式而不是..
css – 不显示背景图像的元素
尽管我已经设置了要显示的“a”元素的宽度和高度.
有谁能够帮我?
码.
<div> <a href="#"https://www.jb51.cc/tag/heading/" target="_blank">heading/TopMenu.gif');width:176px;height:25px;margin-left:8px;margin-right:8px;"> </a> <a href="#"https://www.jb51.cc/tag/heading/" target="_blank">heading/TopMenu.gif');width:176px;height:25px;margin-left:8px;margin-right:8px;"> </a> <a href="#"https://www.jb51.cc/tag/heading/" target="_blank">heading/TopMenu.gif');width:176px;height:25px;margin-left:8px;margin-right:8px;"> </a> <a href="#"https://www.jb51.cc/tag/heading/" target="_blank">heading/TopMenu.gif');width:176px;height:25px;margin-left:8px;margin-right:8px;"> </a> <a href="#"https://www.jb51.cc/tag/heading/" target="_blank">heading/TopMenu.gif');width:176px;height:25px;margin-left:8px;margin-right:8px;"> </a> </div>
我确信这是愚蠢的,但我不知道是什么.
解决方法
因此,您需要使用CSS属性显示更改元素的显示模式.
使用display:block;如果你希望你的元素从文本流中取出并被认为是一个块(即:垂直堆叠,每行一个块).
使用display:inline-block;如果你希望你的元素行为像内联元素位置明智,但具有类似块的属性.
注意:< a>上的IE6支持内联块.在IE6中,仅在具有内联默认样式的元素上支持内联块显示样式.
css – 使背景图像显示在一个空白的div元素中
我需要这样做,因为我想在一些文本旁边显示图形,但图形与文本垂直对齐.
如何让背景图像显示在空白的div中?
我的Google-fu失败了我.
<div> lorem ipsum | <divhttps://www.jb51.cc/tag/dis/" target="_blank">display:inline;"></div> </div>
谢谢!
编辑:
下面的代码实际上显示了图像,但我只需要像2或3像素一样将其完全对齐.
这就是我想要实现的任何想法?
<div> Added<span>•</span>Wed Apr 01,2009 1:01 pm<span>•</span>64.10 KB<span>•</span>659x878 pixels <span>•</span> <img src="/_assets/img/icons/new-photo-small.gif" /> </div> <!--<divhttps://www.jb51.cc/tag/dis/" target="_blank">display:inline-block;"></div>--> .photoInfo { font-size:0.6em; color:#b0bad9; padding-bottom:15px; text-align:center; }
解决方法
one | <span>two</span> | three
如果您使用div而不是span,则需要在样式中设置display:inline.
css – 在Firefox中不显示背景图像
CSS示例:
div.something { background:transparent url(../images/table_column.jpg) repeat scroll 0 0; }
(这个问题在很多地方都有描述,但没有看到任何确凿的解释或修正.)
解决方法
可能性1
您可能会发现CSS文件的路径不正确.例如:
说我有以下文件结构:
public/ css/ global.css images/ background.jpg something/ index.html index.html
在public / index.html上,以下路径将包含CSS文件:
#1: <link href="./css/global.css" #2: <link href="/css/global.css" #3: <link href="css/global.css"
但是在public / something / index.html数字1和3将失败.如果您使用这样的目录结构(或MVC结构,例如:http:// localhost / controller / action / params),请使用第二个href类型.
Firebug的网络监视器选项卡将告诉您是否不能包含CSS文件.
关于路径的问题,请记住,图像是相对于CSS文件的路径.所以:
url('./images/background.jpg') /* won't work */ url('../images/background.jpg') /* works: ../ == up one level */
将鼠标悬停在Firebug的CSS选项卡中的背景属性的url()部分,以检查是否正在加载该文件.
可能性2
这可能是div没有内容,因此具有0高度.确保div至少有一行内容(例如:lorem ipsum delors secorum)或:
div.something { display: block; /* for verification */ min-height: 50px; min-width: 50px; }
检查Firebug的布局选项卡(HTML选项卡),以检查div具有高度/宽度.
今天关于css – 在鼠标上显示背景图像和css中鼠标放上去显示的讲解已经结束,谢谢您的阅读,如果想了解更多关于css – IE8上没有显示背景图像、css – 不显示背景图像的元素、css – 使背景图像显示在一个空白的div元素中、css – 在Firefox中不显示背景图像的相关知识,请在本站搜索。
本文标签: