简体   繁体   English

display:inline-block不起作用?

[英]display:inline-block not working?

I'm working on the homepage of this website and trying to get the category divs under the header to display in a grid, with 3 divs per row. 我正在本网站的首页上工作,尝试将标题下的div类别显示在网格中,每行3 div。

I'm trying to do so using display:inline-block , but I can't seem to get the divs to show horizontally, only vertically. 我正在尝试使用display:inline-block这样做,但是我似乎无法使div水平显示,而只能垂直显示。 I've tried using float:left as well, but was having an entirely different issue with that. 我也尝试过使用float:left ,但是存在一个完全不同的问题。

What can I do to get these divs in a grid format? 我该怎么做才能以网格格式获得这些股利?

Below is my html for each div: 以下是我的每个div的html:

<br /><a href="URL"><div class="home_cat" style="background-image:url('IMAGEURL');">
<p class="home_cat_link">Category Name</p></div></a>

Below is my css: 下面是我的CSS:

.home_cat {
background:#14A1C4;
height:180px;
width:29%;
display:inline-block;
margin:5px;
padding:5px;
}

.home_cat_link {

font-size:3em;
font-family: 'Permanent Marker', cursive;
color:#000;
padding-top:80px;
text-align:center;
}

Thanks in advance for any help! 在此先感谢您的帮助!

You have a bunch of <br> tags in your HTML. HTML中有一堆<br>标记。 This causes the elements to break to the next line. 这将导致元素中断到下一行。 Get rid of them. 摆脱它们。

display: inline-block; is working. 正在工作。 But you can add padding: 0; 但是您可以添加padding: 0; and margin: 0; margin: 0; and will solve the problem. 并会解决问题。

HERE IS DEMO 这里是演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM