0

所以,我在 html 代码中有这个:

<span class="a">Lorem</span>
<span class="b">Ipsum</span>

用这个CSS:

span.a {
    display: block;
    border: 1px solid #60ddfc;
    width: 40%;
    padding: 1%;
    float: left;
}

span.b {
    display: block;
    border: 1px solid #60ddfc;
    width: 40%;
    padding: 1%;
    float: right;

} 

我想做的是让两个跨度总是等长,比如,如果我在第一行有多行但在第二行只有一个,第二行应该和第一行一样长

4

2 回答 2

0

我建议使用flexbox。这样你也不需要花车。

div {
  display: flex;
}

span.a {
  display: block;
  border: 1px solid #60ddfc;
  width: 40%;
  padding: 1%;
}

span.b {
  display: block;
  border: 1px solid #60ddfc;
  width: 40%;
  padding: 1%;
}
<div>
  <span class="a">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</span>
  <span class="b">Lorem Ipsum</span>
</div>

于 2020-06-10T14:41:50.390 回答
0

如果我理解正确,您可以为这两个类创建一个类,以便为所有跨度标签提供相同的属性。

c {
    display: block;
    border: 1px solid #60ddfc;
    width: 40%;
    padding: 1%;
    float: right;
}

你的跨度应该有这些类<span class="a">Lorem</span>。这回答了你的问题了吗?

于 2020-06-10T14:38:43.703 回答