Safari 4似乎忽略了元素边距,除非我添加边框.
以下示例呈现左右边距但没有顶部或底部.
添加边框后,它会按预期呈现.我做错了什么,或者我是否必须(albeit transparent ones)为每个带边距的元素添加边框?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>testing</title>
<style>
body {background-color:#666;}
div {display:block; position:relative; margin:0; padding:0;}
.background {background-color:#990000;}
.foreground {background-color:#fff; margin:10px; padding:10px;}
</style>
</head>
<body>
<div class='background'>
<div class='foreground'>
foreground
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建将位于div中心的寻呼机.基本上代码看起来像这样:
<div class="cms-pager">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
如果我像这样指定CSS:
.cms-pager { }
.cms-pager ul { background-color: somecolor; margin: 0 auto; }
.cms-pager ul li { padding: 5px; margin: 3px; }
Run Code Online (Sandbox Code Playgroud)
然后UL不会居中,因为它在整个div上有宽度/背景颜色.我不会工作.
如果我像这样指定CSS:
.cms-pager { }
.cms-pager ul { width: 200px; background-color: somecolor; margin: 0 auto; }
.cms-pager ul li { padding: 5px; margin: 3px; }
Run Code Online (Sandbox Code Playgroud)
然后UL以页面为中心.问题是我必须指定固定宽度:200px; 如果我只有1或2个链接,它就在中心位置.所以这对我来说不合适,我需要UL真正拥有实际LI标签的宽度并且要按宽度精确指定.
如果我像这样指定CSS:
.cms-pager { margin: 0 auto; }
.cms-pager ul { float: left; background-color: somecolor; margin: 0 auto; }
.cms-pager ul li { …Run Code Online (Sandbox Code Playgroud) 我想将 h2 居中 #top 但 vert-aliignt middle 不能使用相同的自动边距...我不知道该怎么做!
#top {
display: block;
position: relative;
height: 100px;
background-color: rgba(89,144,222,.6);
}
#top h2{
text-shadow: 2px 2px black;
text-align: center;
color: white;
font-family:"Impact";
font-size: 50px;
}
Run Code Online (Sandbox Code Playgroud)
效果是—— 
这是我第二次遇到不必要的滚动条,第一次通过添加body{margin:0;}; 但是,我不知道这次发生了什么。有任何想法吗?
HTML:
<html>
<head>
<link rel="stylesheet" type="text/css" href="Style-Sheets/style.css" />
<!--[if IE]><link rel="stylesheet" type="text/css" href="Style-Sheets/ie.css" /><![endif]-->
<!--[if !IE 7]><link rel="stylesheet" type="text/css" href="Style-Sheets/!ie7.css" /><![endif]-->
<!--[if OPERA]><link rel="stylesheet" type="text/css" href="Style-Sheets/opera.css" /><![endif]-->
<link rel="icon" href="Favicons/favicon.jpg" />
<!--<base target="_blank" />-->
<title>Home</title>
</head>
<body>
<div id="wrap">
<div id="header">
<p class="title">Title</p>
<p class="nav-down"><span class="verticle-bar">|</span> <a class="navigation" href="index.html">Home</a> <span class="verticle-bar">|</span> <a class="navigation" href="about.html">About</a> <span class="verticle-bar">|</span> <a class="navigation" href="blah/index.html">blah</a> <span class="verticle-bar">|</span> <a class="navigation" href="blah2.html">blah2</a> <span class="verticle-bar">|</span></p>
</div>
<div id="body">
</div>
</div>
<div id="footer">
<div class="footer">
<span class="verticle-bar">|</span> 
<a class="footer-link" href="">About The Developer</a> 
<span class="verticle-bar">|</span> …Run Code Online (Sandbox Code Playgroud) 我的网站上有一个侧面导航栏.侧边栏与您一起滑动并更改margin-top.在谷歌浏览器上,它跟随你,而在Firefox中,它使所有框跟随你,这不会让你向下滚动页面. http://jsfiddle.net/rDV3T/这是一个例子.
<span class="hi">HI</span>
<span class="hello">Hello</span>
Run Code Online (Sandbox Code Playgroud)
CSS
.hi {
margin-top: 10px;
background-color: red;
display: inline-table;
}
.hello {
display: inline-table;
}
Run Code Online (Sandbox Code Playgroud)
如果你在firefox上测试,所有的框都会下降10 px,而在chrome中只有指定的框(hi)会下降.我怎么能解决这个问题?谢谢你,对不起我的英语和解释.
我的网页填充了相同类元素的变量编号.我想为每个第2,第5,第8,第11等类(如果存在)设置左右边距.
有没有办法用javascript实现这一点?我不想使用css3子选择器,因为它在旧浏览器上不兼容.
我的div像这样放置:
[div class ="block"] [div class ="block"] [div class ="block"]
[div class ="block"] [div class ="block"] [div class ="block"]
[div class ="block"] [div class ="block"] [div class ="block"]
[div class ="block"] [div class ="block"] [div class ="block"]
我希望每个中间div都有左右边距.
谢谢.:)
我正在尝试以编程方式创建的新形式插入几个对象;基本上,我要Button在底部RichTextBox保留所有剩余空间。我将第一个设置为as Dock = DockStyle.Bottom,后一个设置为Dock = DockStyle.Filland它可以正常工作。
现在,我试图在元素之间插入一个间距,因此我在表单中添加了填充,并在按钮中添加了边距。第一个可以正常运行,但是margin不能正常运行,因此RichTextBoxand 之间没有空格Button。
这是代码和输出。我想念什么吗?
// Parent Form
SMSForm.Padding = new Padding(5);
// TextBox
RichTextBox SMStext = new RichTextBox();
SMSForm.Controls.Add(SMStext);
SMStext.Dock = DockStyle.Fill;
// Button
Button SMSsend = new Button();
SMSsend.Text = "Send SMS to ";
SMSForm.Controls.Add(SMSsend);
SMSsend.Margin = new Padding(10);
SMSsend.Dock = DockStyle.Bottom;
Run Code Online (Sandbox Code Playgroud)

我在 Oxyplot 热图小部件的边缘看到了空间。我想让 X0,X1,Y0,Y1 绘制在热图油漆画布的最边缘,即没有边距和填充。OxyPlot 的 HeatMapSeries 是如何做到的?
我希望 (0, 0) 正好位于左下角。
这是我的目标:有没有缘之间的孩子的一个父母,和25px之间的保证金孩子的在父。见解释图像:
我有这个 HTML 代码:
<div id="parent">
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
和这个CSS:
#parent{
width: 200px;
height: 405px;
}
.child{
width: 50px;
height: 180px;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:为每个孩子添加边距的最佳方法是什么?
我可以:
<div class="child" style="margin: 0px 25px 25px 0px"></div>
Run Code Online (Sandbox Code Playgroud)
但后来我必须对每个孩子都这样做,当我有很多孩子时,这会变得更难。
我指定了绘图的宽度、高度和分辨率,然后删除了下面代码中的边距,并绘制了一个绘图。
但我仍然有利润空间。无论有没有par命令,我都得到了相同的情节。上传的图片从 7000*5000 缩小到 1400*1000,减少到 2MB 以下。
library(scatterplot3d)
parwd = 7000
parht = 5000
parres = 1000
par(oma = c(0,0,0,0), mar = c(0,0,0,0))
jpeg(filename="CC_1_fo.jpg", width = parwd, height = parht, res = parres)
scatterplot3d(1:10, 1:10, 1:10,
cex.symbol = 0.2,
xlab = expression(T[1]),
ylab = expression(T[2]),
zlab = expression(tau))
dev.off()
Run Code Online (Sandbox Code Playgroud)
我怎样才能真正去除边距?