Html 如何在彼此下方放置几个跨度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16239504/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 07:54:31  来源:igfitidea点击:

How to position few span's under each other

csshtml

提问by user2316675

I want to position two span's and a button like so:

我想像这样定位两个跨度和一个按钮:

span1

span2

button

跨度1

跨度2

按钮

But, with my current code they look like this:

但是,使用我当前的代码,它们看起来像这样:

span1 span2 button

span1 span2 按钮

body {
text-align:center;
}
span#printHere {
color:black;
font-size:30px;
position:relative;
}
span#triesLeft{
align='centre';
font-size:30px;
position:relative;
}

回答by gaynorvader

Try:

尝试:

span {
  float: left;
  clear: left;
}
button {
  float: left;
  clear: left;
}
button:hover {
  background-image: url('imageurl');
}

clearing after a float will cause the span to drop to a new line. http://jsfiddle.net/aKmF6/

浮动后清除将导致跨度下降到新行。 http://jsfiddle.net/aKmF6/

回答by Darren

spanare inline elements. If you want them positioned under each other use a block element or style it with display:block

span是内联元素。如果您希望它们位于彼此下方,请使用块元素或将其样式设置为display:block

http://jsfiddle.net/xfyS4/

http://jsfiddle.net/xfyS4/