我使用Firefox 8.0.1
margin-top没有按预期工作,有人可以帮忙吗?谢谢.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>New Border</title>
<style type="text/css">
#page {
width:980px;
margin: 50px auto;
}
#board {
width:600px;
height:400px;
background-color: gray;
}
.cell {
border: 1px solid;
width:50px;
height:20px;
margin: 30px 5px;
}
</style>
</head>
<body>
<div id="page">
<div id="board">
<div class="cell">
</div>
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
所以,margin-top在celldiv中没有按预期工作.
我认为应该将div margin-left放在celldiv之下board,但事实并非如此.
这是截图:

我正在从事计算机科学项目,但我无法找到解决问题的方法.我正在创建一个JPanel包含图像的二维数组GridLayout.我想删除所有面板之间的填充/边距,使其无缝地流入单个图像.但是,setHGap和setVGap方法似乎对我没有帮助.我很感激任何回应.谢谢.
import java.awt.GridLayout;
import java.util.Map;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class MapArray {
static JPanel[][] tiles = new JPanel[11][11];
public MapArray() {
}
protected static ImageIcon createImageIcon(String path) {
java.net.URL imgURL = Map.class.getResource(path);
if (imgURL != null) {
return new ImageIcon(imgURL);
} else {
System.err.println("Couldn't find file: " + path);
return null;
}
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frame = new …Run Code Online (Sandbox Code Playgroud) 我有一个谷歌可视化图表和图表顶部的图表.
这些是我的图表选项:
var chartOptions ={
width: 700, height: 500,
chartArea: {width: '80%', height: '80%', top:20},
legend: {position: 'top'},
titlePosition: 'in',
axisTitlesPosition: 'in',
hAxis: {showTextEvery: '1', textPosition: 'out'},
vAxis: {textPosition: 'out'}
}
Run Code Online (Sandbox Code Playgroud)
我想知道是否有办法设置legenda和图形之间的边距,或者我可能通过设置这些选项搞砸了一些东西.
提前致谢.
我正在尝试将加载图像放在页面的右侧,但除了margin-bottom之外,一切正常.
<div id="preload">
<div align="right" style="margin-bottom:40px; margin-right:50px;">
<img src="http://thc-racing.ucoz.com/design/loading.gif" alt="" />
<br>
<a style="color:#00ff24;"><b>Please wait while the page is loading...
<br>If the website doesn't load within one minute please refresh your page!</b>
</a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我它是什么或如何使它工作?谢谢
这是我的HTML:
<div id="Header">
<div id="logoContainer">
<p id="welcome">Welcome</p>
<h1 class="logoText">first<img id="logoImage" src="image.jpeg" /><span id="second">second</span></h1>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我的CSS:
#Header {
font-family: consola;
width: 100%;
height: 50px;
background-color: black;
color: white;
}
#logoContainer {
height: 50px;
width: 200px;
background-color: red;
}
#welcome {
font-weight: 500;
font-size: 8px;
margin-bottom: -6px;
}
#logoImage {
width: 14px;
vertical-align: -4px;
padding-left: 5px;
padding-right: 5px;
}
.logoText {
font-size: 12px;
font-weight: 500;
}
#second {
font-weight: 500;
}
Run Code Online (Sandbox Code Playgroud)
现在,当我改变
#logoContainer
Run Code Online (Sandbox Code Playgroud)
至
#logoContainer {
height: 50px;
width: 200px;
background-color: …Run Code Online (Sandbox Code Playgroud) <div class ="cards">
<span id="cardtitle">
Chance
</span>
<span id="cardinfo">
Your ass is going to jail.
</span>
</div>
Run Code Online (Sandbox Code Playgroud)
.cards{
background: #F8F8F8 ;
height: 100px;
margin: 0 auto;
width: 200px;
}
#cardtitle, #cardinfo{
background: #ffcc00;
display: block;
margin-top: 10px;
width: 100px;
}
Run Code Online (Sandbox Code Playgroud)
好吧,保证金最高可行,#cardinfo但#cardtitle没有.问题似乎是第一个因素,因为如果我尊重2个跨度,问题就会逆转.
我有一个div与css水平居中:
.bar {
height: 38px;
width: 970px;
margin-left: auto;
margin-right: auto;
}
Run Code Online (Sandbox Code Playgroud)
我需要有另一个元素从右边有相同的边距作为.bar,所以我使用jQuery大小:
<div class="spec">I need to be aligned the same.</div>
Run Code Online (Sandbox Code Playgroud)
JS:
$(".spec").css('margin-right', $('.bar').margin().right + 'px');
Run Code Online (Sandbox Code Playgroud)
这有效,但在Firefox 30.0中没有,因为它为.bar的计算margin-right 返回0.有什么建议 ?http://jsbin.com/difobu/1/edit.
$('.bar').css('margin-right')也在FF 30.0中返回0px. 如果您投票,请提供解释.
我在div中调用一个span,它占用边距但是边距:0 auto不起作用.有什么建议吗?
HTML
<div>
<span>
<h3>Paris Eurostar Breaks</h3>
<p>Curabitur fringilla mauris interdum nec magna</p>
</span>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
div{
width:465px;
min-height:201px;
}
div span{
display:inline-block;
color:#FFF;
border-bottom:1px #FFF solid;
border-top:1px #FFF solid;
margin:0 auto;
}
Run Code Online (Sandbox Code Playgroud)
需要输出

这看起来很简单.我试图在父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) 我有一个带有div的html/css.我希望它能拉出自己宽度的100%.现在它拉动了100%的屏幕.
从长远来看,我将在顶部添加一个CSS动画.
https://jsfiddle.net/5L7a5pfr/
HTML
<div class="test left">
testing something
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.test {
position: fixed;
background: green;
color: #fff;
top: 0;
left: 0;
}
.left {
left: -100%;
}
Run Code Online (Sandbox Code Playgroud)