html - 样式未应用于 div 而它位于不同的 div

标签 html css bootstrapper

我有以下风格

.MapField {
    width:70px;
    height:70px;
}
.MapTab
{
    width:auto;
    height:auto;
}
div[worldTexture="1"] {
    background:url(../WorldTextures/dirt.jpg);
}

然后我有以下 html 片段

<div class="col-xs-9 MapTab">
  <div class="col-xs-6 MapField" worldTexture="1"/>
  <div class="col-xs-6 MapField" worldTexture="1"/>
</div>
<div class="col-xs-3"></div>

然后我希望 col-xs-6 的高度至少为 70px(以防屏幕尺寸允许)但它会导致 div 大小如 width:70px height:1px.MapStyle 更改为具有 widthheight !important 不会改变任何内容

另一方面,如果我按以下方式将 div 的用法更改为 table

td[worldTexture="1"] {
    background:url(../WorldTextures/dirt.jpg);
}

<table>
<tr class="col-xs-9 MapTab">
  <td class="col-xs-6 MapField" worldTexture="1"/>
  <td class="col-xs-6 MapField" worldTexture="1"/>
</tr>
<tr class="col-xs-3"></div>
<table>

它按预期工作,知道这里可能出了什么问题吗?

最佳答案

我认为那些 div 不应该是自闭合标签。

尝试

<div class="col-xs-9 MapTab">
  <div class="col-xs-6 MapField" worldTexture="1"></div>
  <div class="col-xs-6 MapField" worldTexture="1"></div>
</div>
<div class="col-xs-3"></div>

关于html - 样式未应用于 div 而它位于不同的 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41946973/

相关文章:

c# - WiX Bootstrap 创建的设置未启动

html - 根据可用空间水平或垂直格式化列表

css - 为什么我的导航栏仍在水平滚动(Bootstrap)

css - 如何在SASS中将分数放在单位前面

javascript - 使用 javascript(或 jQuery)选择和操作 CSS 伪元素,例如::before 和::after

html - 页脚在特定内容长度消失

javascript - 我可以将变量分配为数组值吗?

html - CSS3 布局网格 - 粘性标题

ubuntu - Gentoo + debootstrap 在与 fakeroot 和 fakechroot 一起使用时失败

wix - 在链中执行 MSI 文件时,如何阻止 WiX 传递 ARPSYSTEMCOMPONENT ="1"?