Html 将 <span> 浮动在右侧,其余(文本)在左侧,在 ie 7 中的 <div> 内
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17470553/
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
Float <span> on right and the rest(text) on left, within <div> in ie 7
提问by RAN
I have some text and <span>
tag, which are inside a <div>
.
我有一些文本和<span>
标签,它们在<div>
.
<span>
is float: right;
I need the text to be on the left side and <span>
on right side.
<span>
是float: right;
我需要的文本是在左侧,<span>
在右侧。
In every browser it displays perfectly except ie7
. How can I fix this bug?
在每个浏览器中,它都能完美显示,除了ie7
. 我该如何修复这个错误?
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title> Testing page</title>
</head>
<body>
<div style="border:2px solid #000; display:inline;">
welcome<span style="float:right"> demo</span>
</div>
</body>
</html>
回答by simoncereska
move span before text, this should help.
在文本之前移动跨度,这应该会有所帮助。
回答by wanderlust
Make spanas block element and move it.
将span作为块元素并移动它。
I.e.
IE
span{
display: block;
float: right;
}
回答by icedwater
Would it be possible to enclose the text in a <p>
and have that display: inline
?
是否可以将文本括在 a 中<p>
并拥有它display: inline
?
回答by Swarnamayee Mallia
User the following css it will work. DEMO LINK
用户使用以下 css 它将起作用。演示链接
*{
padding:0;
margin:0;
}
body {
font:normal 12px/18px Arial, Helvetica, sans-serif;
color:#000;
padding:20px;
}
.container {
border:2px solid #000;
padding:20px;
overflow:hidden;
height:100%;
}
.container span {
display:inline-block;
*float:left;
}