我正在尝试将一些图片移动到表格的左侧,使用 class="pull-left"
或 float: left;
不会有问题>。问题是每当我使用这些时,我都无法改变两者之间的距离。我想这是因为这两个里面的 div 太小了,所以我试图找到一种方法来增加 div 的大小,以便我可以调整边距和填充。我还想将图片向下移动一点,但由于 pull-left
和 float:left
也不起作用。
这是 HTML:
<div style="marging: 5%; display:inline-block;">
<img class="pull-left" src="some picture" alt="Öffnungszeiten">
<table class="wpTbOeffnungszeiten">
<tr><th colspan="2">Headline</th></tr>
<tr>
<td>Some text</td>
<td>Some text</td>
</tr>
<tr>
<td>Some text</td>
<td>Some text</td>
</tr><tr>
<td>Some text</td>
<td>Some text</td>
</tr><tr>
<td>Some text</td>
<td>Some text</td>
</tr><tr>
<td>Some text</td>
<td>Some text</td>
</tr><tr>
<td>Some text</td>
<td>Some text</td>
</tr>
<tr><th colspan="2">Headline</th></tr>
<tr>
<td>Some text</td>
<td>Some text</td>
</tr>
<tr>
<td>Some text</td>
<td>Some text</td>
</tr>
<tr>
<td>Some text</td>
<td>Some text</td>
</tr>
</table>
</div>
</div>
这是我的 CSS:
background-image: url("some image");
.wpTbOeffnungszeiten {
margin: 5%;
}
th {
color: $red;
font-weight: bold;
}
最佳答案
像 .pull-left
这样的类我假设您正在将 Bootstrap 集成到您的元素中,但您的示例代码中不存在 CSS。虽然以该假设运行,但添加 .pull-right
给你的<table>
并提供有效的 width
为你的 parent <div>
(内联样式为 display: inline-block
)应该可以解决问题。
还要检查您的拼写,同样的内联样式有一个拼写错误 margin
关于html - 增加一个div的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38224713/