简体   繁体   English

使用display:inline-table将第二个inline框向下移动一点

[英]using display:inline-table move second inline box little bit down

I am very new in CSS, HTML, and any other UI related technologies, so please accept my apology if this question is not a clever one! 我在CSS,HTML和其他任何与UI相关的技术上都是新手,所以如果这个问题不是一个聪明的问题,请接受我的道歉!

I want multiple boxes with background image to be clickable and have a text in the middle (horizontally and vertically). 我希望带有背景图像的多个框可单击,并且中间有一个文本(水平和垂直)。

I have Html code as below: 我有如下的HTML代码:

<a href="www.mydoamin.com" class="div_a">
    <span class="wrapper">
      <span class="div_txt">Contentdas asd ad adasd asd asdad </span>
    </span>
</a>
<a href="www.mydoamin.com" class="div_a">
    <span class="wrapper">
      <span class="div_txt">Content</span>
    </span>
</a>

with following CSS code: 使用以下CSS代码:

a.div_a {
      display:inline-table;
      width:200px;
      height:100px;
      background-color:#CCC;
      background-image:url( http://jsfiddle.net/img/logo.png);
    text-align:center;
    top:0;
    }

.wrapper {
    display: table-cell;
    vertical-align: middle;

}

As you can see HERE everything sounds fine except that the second box is misplaced when inside text of the first one exceeds one line!! 正如你可以看到这里的一切听起来只是罚款时,里面的第一个文本超过一行的第二个框是错误的!

Have I missed something here? 我在这里错过了什么吗?

Thanks in advance for your help. 在此先感谢您的帮助。

Your element that's set to inline-table just needs its vertical-align set to something other than the default of baseline : 设置为inline-table元素只需要将其vertical-align设置为除baseline默认值以外的值即可:

vertical-align: middle;

http://jsfiddle.net/WcCnW/4/ http://jsfiddle.net/WcCnW/4/

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

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