HTML/CSS中是否有任何东西告诉浏览器完全忽略空格?
很多时候,当你想把两个图像放在一起时 - 你会拼命地保持HTML的可读性,但浏览器会在它们之间留一个空格.
所以不是这样的:
<img src="images/minithing.jpg" alt="my mini thing" />
<img src="images/minithing.jpg" alt="my mini thing" />
<img src="images/minithing.jpg" alt="my mini thing" />
<img src="images/minithing.jpg" alt="my mini thing" />
Run Code Online (Sandbox Code Playgroud)
你最终得到了这个
<img src="images/minithing.jpg" alt="my mini thing" /><img src="images/minithing.jpg" alt="my mini thing" /><img src="images/minithing.jpg" alt="my mini thing" /><img src="images/minithing.jpg" alt="my mini thing" />
Run Code Online (Sandbox Code Playgroud)
哪个太可怕了!
我尝试使用百分比作为宽度来构建流体布局.这样做我试过这个:
<div style="width:50%; display:inline-table;">A</div>
<div style="width:50%; display:inline-table;">B</div>
Run Code Online (Sandbox Code Playgroud)
在这种情况下,他们不会站在一行,但如果我删除它们之间的换行符,像这样:
<div style="width:50%; display:inline-table;">A</div><div style="width:50%; display:inline-table;">B</div>
Run Code Online (Sandbox Code Playgroud)
然后它工作正常.问题出在哪儿?我怎么能这样做,但没有使用绝对位置和浮动.
抱歉英语.我希望我能很好地解释我的问题
我想在Boilerplate HTML模板中使用Paul Irish的条件评论:
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
Run Code Online (Sandbox Code Playgroud)
在SharePoint 2010母版页中.我读过'有条件的评论在SP2010中并不总是那么好用'.(不知道这意味着什么!)建议是使用:
<SharePoint:CSSRegistration Name="foo.css" ConditionalExpression="gte IE 7" runat="server" />
Run Code Online (Sandbox Code Playgroud)
这允许我使用条件来加载特定样式表,但不使用Paul Irish建议的方式使用条件html标记.有没有办法做到这一点,还是只需将Biolerplate中的代码粘贴到Sharepoint主页中?
有人可以解释为什么以下代码不起作用?
<div id="content">
<div class="sidebar">1</div>
<div class="sidebar">2</div>
</div>
Run Code Online (Sandbox Code Playgroud)
#content {
padding:0;
margin:0;
}
.sidebar {
width: 50%;
display: inline-block;
margin: 0;
padding: 0;
}
Run Code Online (Sandbox Code Playgroud)
我希望侧边栏可以并排,但它们不是.我甚至不知道从哪里开始.我知道我可以使用float: left,但我怎样才能使用它inline-block?
这看起来很简单.我试图在父div中获得10个div,所有10%宽.父div为960px,并以页边距为中心,边距为:0 auto,背景为红色.如果我使用.tenPercent 10%或96px并不重要.结果是相同的,只有9个适合和第10个包装.看起来有一个左边距(或填充可能),但是会导致这种情况?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
.tenPercent
{
color:Black;
display:inline-block;
border:1px solid black;
width:10%;
}
</style>
</head>
<body>
<div style="width:960px;background-color:Red;margin:0 auto">
<div class="tenPercent">1</div>
<div class="tenPercent">2</div>
<div class="tenPercent">3</div>
<div class="tenPercent">4</div>
<div class="tenPercent">5</div>
<div class="tenPercent">6</div>
<div class="tenPercent">7</div>
<div class="tenPercent">8</div>
<div class="tenPercent">9</div>
<div class="tenPercent">10</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) bikesheddingCSS3属性还有其他选择吗?它似乎还没有得到支持.
我已经设置了960px宽度的页面包装器.我创建了2个块来填充包装宽度,因此我将单独块的宽度设置为50%,但这两个块在te包装中并不适合.
我想这与单独块的1px实线边界有关.具有1px边框的块是否会是50%宽度+ 1px边界?
如何在不删除1px边框的情况下解决此问题?
css ×6
html ×3
boilerplate ×1
css3 ×1
html5 ×1
inline ×1
margin ×1
master-pages ×1
polyfills ×1
sharepoint ×1
shim ×1
w3c ×1
whitespace ×1
width ×1