我希望我的页面输出如下:
但相反它是这样的:
你能提出我应该做些什么?代码是模板和CSS:
BODY {background-image: url(/welcome/static/images/register_top2.png); background-repeat: repeat-x; }
#content {
width: 700px ;
margin: 180 auto;
}
#content-container {
width: 700px ;
margin-left: 180px;
}
#image-logo {
float: right;
}
.has_errors { border: 1px solid #ff0000 }
.errors {color: #ff0000;}
<!DOCTYPE hml>
<html>
<head> <link rel="stylesheet" href="/welcome/static/css/register.css"/>
<STYLE TYPE="text/css">
</STYLE>
<title>{% trans %}Register new distributor{% endtrans %}</title> <script type="text/javascript" src="/welcome/static/js/jquery-1.7.1.js"></script>
<script type="text/javascript" src="/welcome/static/js/jquery.popupWindow.js"></script>
</head>
<body>
<div id="content"><img src="/welcome/static/images/reg-reg3.gif">
<div id="content-container">
<form action="{{action}}" method="post">
<table><tr><td>
<label>{% trans %}Soc security number{% endtrans %}</label></td><td>{{ form.soc_sec(size='10', maxlength='10')}}({% trans %}YYMMDDXXXX{% endtrans %})</td></tr>
{% if form.soc_sec.errors %}<tr><td></td><td> <div class="red">
<ul class="errors">{% for error in form.soc_sec.errors %}<li>{{ error }}</li>{% endfor %}</ul></div></td></tr>
{% endif %}
<tr><td>
<label for="start">{% trans %}Your sponsor's ID{% endtrans %}</label></td><td>
<input id="log1" {% if form.sponsor_id.errors %}class="has_errors "{% endif %} maxlength="3" name="sponsor_id-log1" size="3" type="text" value="{% if form.sponsor_id.log1.data %}{{form.sponsor_id.log1.data}}{% endif %}" />
<input id="log2" {% if form.sponsor_id.errors %}class="has_errors "{% endif %} maxlength="3" name="sponsor_id-log2" size="3" type="text" value="{% if form.sponsor_id.log2.data %}{{form.sponsor_id.log2.data}}{% endif %}" />
<input id="log3" {% if form.sponsor_id.errors %}class="has_errors "{% endif %} maxlength="3" name="sponsor_id-log3" size="3" type="text" value="{% if form.sponsor_id.log3.data %}{{form.sponsor_id.log3.data}}{% endif %}" />
<input id="log4" {% if form.sponsor_id.errors %}class="has_errors "{% endif %} maxlength="3" name="sponsor_id-log4" size="3" type="text" value="{% if form.sponsor_id.log4.data %}{{form.sponsor_id.log4.data}}{% endif %}" />
(<a class="open_dialog" href="/static/sponsor-id.html">{% trans %}What is a sponsor ID{% endtrans %}?</a>)</td><td></tr>
{% if form.sponsor_id.log1.errors %}
<tr><td></td><td> <div class="red">
<ul class="errors">{% for error in form.sponsor_id.log1.errors %}<li>{{ error }}</li>{% endfor %}</ul></div></td></tr>
{% endif %}
<tr><td>
<label>Email</label></td><td> {{ form.email(size='22', maxlength='60')}} </td></tr>
{% if form.email.errors %}<tr><td></td><td> <div class="red">
<ul class="errors">{% for error in form.email.errors %}<li>{{ error }}</li>{% endfor %}</ul></div></td></tr>
{% endif %}
<tr><td>
<label>{% trans %}First name{% endtrans %}</label></td><td>{{ form.firstname(size='22', maxlength='60')}}</td></tr>
{% if form.firstname.errors %}<tr><td></td><td> <div class="red">
<ul class="errors">{% for error in form.firstname.errors %}<li>{{ error }}</li>{% endfor %}</ul></div></td></tr>
{% endif %}
<tr><td>
<label>{% trans %}Last name{% endtrans %}</label></td><td>{{ form.lastname(size='22', maxlength='60')}}</td></tr>
{% if form.lastname.errors %}<tr><td></td><td> <div class="red">
<ul class="errors">{% for error in form.lastname.errors %}<li>{{ error }}</li>{% endfor %}</ul></div></td></tr>
{% endif %}
<tr>
<td>
<label>{% trans %}Address{% endtrans %}</label></td><td>{{ form.address(size='22', maxlength='60')}}</td></tr>
{% if form.address.errors %}<tr><td></td><td> <div class="red">
<ul class="errors">{% for error in form.address.errors %}<li>{{ error }}</li>{% endfor %}</ul></div></td></tr>
{% endif %}
<tr><td>
<label>{% trans %}Zip code{% endtrans %}</label></td><td>{{ form.zipcode(size='22', maxlength='60')}}</td></tr>
{% if form.zipcode.errors %}<tr><td></td><td> <div class="red">
<ul class="errors">{% for error in form.zipcode.errors %}<li>{{ error }}</li>{% endfor %}</ul></div></td></tr>
{% endif %}
<tr><td>
<label>{% trans %}City{% endtrans %}</label></td><td>{{ form.city(size='22', maxlength='60')}}</td></tr>
{% if form.city.errors %}<tr><td></td><td> <div class="red">
<ul class="errors">{% for error in form.city.errors %}<li>{{ error }}</li>{% endfor %}</ul></div></td></tr>
{% endif %}
<tr><td>
<label>{% trans %}Phone{% endtrans %}</label></td><td>{{ form.phone(size='22', maxlength='60')}}</td></tr>
{% if form.phone.errors %}<tr><td></td><td> <div class="red">
<ul class="errors">{% for error in form.phone.errors %}<li>{{ error }}</li>{% endfor %}</ul></div></td></tr>
{% endif %}
</table>
<button>{% trans %}Next{% endtrans %}</button>
</form> </div>
<img id="image-logo" src="/welcome/static/images/snabbreg002.jpg" />
</div><script type="text/javascript">
$('.open_dialog').popupWindow({
height:500,
width:700,
top:325,
left:400
});
</script>
</body>
</html>
答案 0 :(得分:6)
您是否尝试过添加background-position: center top
?
答案 1 :(得分:1)
正如上面的海报所说。他的回答是正确的。这是我如何标记它。实际上,我刚刚获得了Gedit3的Zen Coding,我希望看到所有HTML看起来非常快:)。我现在使用HTML5标记,但我只是通过div风格来实现它,因为大多数人都是自定义的。我把时间花在了以后,根据接受的答案提供额外的信息。
#header {
background-position: center top;
background-repeat: no-repeat;
vertical-align: top;
background-image: url('/foo/bar.png')
}
.wrapper {
margin: 0 auto;
}
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<div id="page">
<div class="wrapper">
<div id="header">
<div id="logo"></div>
</div>
<div class="clearfix"></div>
<div id="body">
<div class="content_wrapper">
<div class="body"></div>
<div class="col1"></div>
<div class="clearfix"></div>
</div>
</div>
</div>
</div>
</html>