我有一个图像,我想显示它在X轴上,但我不想在Y轴上重复属性:
我希望图像不显示为背景,因为我希望另一个图像作为背景图像。有可能吗?如果有,怎么办?
我的CSS和HTML是:
BODY {background-image: url(/welcome/static/images/register_top2.png); background-position: center top; repeat-x; no repeat-y }
#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>
最佳答案
这样写:
body {
background-image: url(/welcome/static/images/register_top2.png);
background-position: center top;
background-repeat:repeat-x;
}
或者你也可以这样写:
body {
background: url(/welcome/static/images/register_top2.png) center top repeat-x;
}
关于css - 如何仅在水平方向上重复图像?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9462645/