Div与背景图像和没有内容不显示 [英] Div with background image and no content not displaying

查看:521
本文介绍了Div与背景图像和没有内容不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在我的页面上有一个div,我给出了一个背景图片。这个div没有任何内容,所以它不会显示在我的页面上,如果我添加它显示的任何内容。即使没有内容,我也希望它显示,因为我希望显示背景图像以及我想为其分配一些悬停/点击事件。



有没有办法强制div显示?

解决方案

您需要指定尺寸:

 < div style =width:100px; height:100px>< / DIV> 

您可以将尺寸设置为背景图片的尺寸或您希望的任何其他值。 / p>

I currently have a div on my page that I have given a background image. This div does not have any content and so it does not display on my page, if I add any content it displays. I would like it display even without content because I want that background image to show up as well as I would like to assign some hover/click events to it.

Is there any way to force the div to display?

解决方案

You need to specify a size:

<div style="width: 100px; height: 100px"></div>

You can set the size to the dimensions of your background image, or any other values you desire.

这篇关于Div与背景图像和没有内容不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆