Reputation: 26637
I'm working with HTML and CSS and I want to align the form and the logo more to the right:
The positions I want are more like this if I do a mockup:
My HTML is
<!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>
</head>
<body> <div id="content">
<form action="{{action}}" method="post"><img src="/welcome/static/images/reg-reg.gif">
<table><tr><td>
<label>Pers. number </label></td><td><input type="text" name="soc_sec" placeholder="{% trans %}Your social security number{% endtrans %}" />({% trans %}YYMMDDXX{% endtrans %})</td></tr><tr><td>
<label for="start">Sponsor ID</label></td><td>
<input type="text" id="start" name="Log1" size="3" maxlength="3" />
<input type="text" name="Log2" size="3" maxlength="3" />
<input type="text" name="Log3" size="3" maxlength="3" />
<input type="text" name="Log4" size="3" maxlength="3" />(<a href="/sponsor-id-info.html">{% trans %}What is a sponsor ID{% endtrans %}?</a>)</td><td></tr><tr><td>
<label>Email</label></td><td> <input type="text" name="email" placeholder="{% trans %}Your email{% endtrans %}" /></td></tr><tr><td>
<label>{% trans %}First name{% endtrans %}</label></td><td><input type="text" name="firstname" placeholder="{% trans %}Your first name{% endtrans %}" /></td></tr><tr><td>
<label>{% trans %}Last name{% endtrans %}</label></td><td><input type="text" name="lastname" placeholder="{% trans %}Your last name{% endtrans %}" /></td></tr><tr>
<td>
<label>{% trans %}Address{% endtrans %}</label></td><td><input type="text" name="address" placeholder="{% trans %}Your address{% endtrans %}" /></td></tr><tr><td>
<label>{% trans %}Zip code{% endtrans %}</label></td><td><input type="text" name="zipcode" placeholder="{% trans %}Your zip code{% endtrans %}" /></td></tr><tr><td>
<label>{% trans %}City{% endtrans %}</label></td><td><input type="text" name="city" placeholder="{% trans %}City{% endtrans %}" /></td></tr><tr><td>
<label>{% trans %}Phone{% endtrans %}</label></td><td><input type="text" name="phone" placeholder="{% trans %}Your phone number{% endtrans %}" /></td></tr></table>
<button>{% trans %}Next{% endtrans %}</button>
</form><img src="/welcome/static/images/snabbreg002.jpg"></div>
</html>
And my CSS is
BODY {background-image: url(/welcome/static/images/reg-bg.png); background-repeat: repeat-x; }
#content {
width: 700px ;
margin-left: auto ;
margin-right: auto ;
}
Could you advice how to align my components more to the right like in the lower picture?
Thank you
Now I could align the logo to the right, all that is left to be done is moving the form to the right. How do I do it?
Upvotes: 4
Views: 63393
Reputation: 2324
float:right on the element you want to be moved to the right on the same level
Upvotes: 1
Reputation: 12447
Your css is right, but try to apply it to a div inside the content div:
Html:
<div id="content">
<div id="content-container">
<form ...>
...
</form>
<img id="image-logo" .../>
</div>
</div>
Css:
#content-container {
width: 700px ;
margin: 0 auto;
}
#image-logo {
float: right;
}
Also, the image needs a right floating to position as you expect.
Upvotes: 6
Reputation: 1086
You could try this:
#content {
position: absolute;
margin-left: 600px;
top: 400px;
}
You have to put the right pixels count in.
Upvotes: 2
Reputation: 29960
You may wrap the form in a div and style the div with the appropriate left margin. You may also try to align the image to the right instead of the left.
Upvotes: 1
Reputation: 10384
Add style="float:right"
to your image.
give the style margin-left:10px;
for example to your form
Upvotes: 2
Reputation: 836
The easiest way is probably using float and/or margin.
You can right position your elements with float, float:right;
.
Also have a look at margin, example : margin-left:100px;
<img src="/welcome/static/images/snabbreg002.jpg" style="float:right;">
Or with css.
<img src="/welcome/static/images/snabbreg002.jpg" class="img">
css:
.img{
float:right;
}
Upvotes: 3