0

I can't seem to center align my background image. I am new to php, css, and java coding but finding it necessary in this day and age. Here is the code. I hope this will help.

 <style>
body{ background: url(http://dsninformation.com/images/magic.jpg); background-repeat: no-repeat }
.button {
display : inline-block;
cursor : pointer;
border-radius:10px;
padding : 20px 60px;
color : #fff;
border:1px solid #ddd;
font-size:30px;
line-height:40px;
font-family: 'Oswald', sans-serif;
text-decoration : none;
}
.button.green {
background: #df3535; /* Old browsers */
background: -moz-linear-gradient(top, #df3535 1%, #9b0606 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#df3535), color-stop(100%,#9b0606)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #df3535 1%,#9b0606 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #df3535 1%,#9b0606 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #df3535 1%,#9b0606 100%); /* IE10+ */
background: linear-gradient(to bottom, #df3535 1%,#9b0606 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#df3535', endColorstr='#9b0606',GradientType=0 ); /* IE6-9 */
}
#mainForm {
left: 785px;
position: absolute;
top: 640px;
}
@-webkit-keyframes spaceboots {
0% { -webkit-transform: translate(2px, 1px) rotate(0deg); }
10% { -webkit-transform: translate(-1px, -2px) rotate(-1deg); }
20% { -webkit-transform: translate(-3px, 0px) rotate(1deg); }
30% { -webkit-transform: translate(0px, 2px) rotate(0deg); }
40% { -webkit-transform: translate(1px, -1px) rotate(1deg); }
50% { -webkit-transform: translate(-1px, 2px) rotate(-1deg); }
60% { -webkit-transform: translate(-3px, 1px) rotate(0deg); }
70% { -webkit-transform: translate(2px, 1px) rotate(-1deg); }
80% { -webkit-transform: translate(-1px, -1px) rotate(1deg); }
90% { -webkit-transform: translate(2px, 2px) rotate(0deg); }
100% { -webkit-transform: translate(1px, -2px) rotate(-1deg); }
}
.shake,.shake:hover,
.shake:focus {
-webkit-animation-name: spaceboots;
-webkit-animation-duration: 0.8s;
-webkit-transform-origin:50% 50%;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
}
.shake {
display:inline-block
}
.red{color:red;}
input[type=text]{
margin-top:10px;width:350px;font-size:18px;height:40px;border:1px solid #ddd;background:#fff;padding-left:5px;
}
#heading{
font-size:30px;
font-weight:bold;
font-family:"Myriad Pro";
width:450px;
text-align:center;
margin:100px auto 0;
}
#info{
width:460px;
font-size:16px;
font-weight:bold;
text-align:center;
margin:15px auto 0;
}
#Table_01 tr td #heading {
color: #FF0;
}
#Table_01 tr td #heading {
color: #F00;
}
  </style>

I would really appreciate any help getting this image center align

3
Contributors
5
Replies
29
Views
3 Years
Discussion Span
Last Post by douglas.shrader.1
0

Seems to be centered on the screen just fine. Where/what resolution do you seem to be having a problem with?

[edit]... i see that you are reffering to the form now...that didnt load before so I saw your image centered...be back..

Ok, I'm back...

first, as I recommened to you in a previous similar thread, you should consider moving away from using table and deprecated elements and properties. Also, your image is too big and rather than assigning it as a background image to the body element, you may consider doing that to a div that is centered on the screen or as I did in my example below, just add an image element.

Take a look at this sample, as it may help guide you to a final solution.

Regarding your image being too big, I downloaded your image and cropped it to a smaller size. this way it will fit on all modern resolutions.

<!DOCTYPE html>
<html>
<head><title>MagicGrab</title>
<style>
#main {width:757px;margin: 0 auto;position:relative;}
#mainForm {position:absolute;bottom:-150px;left:200px;}
#mainFormSubmitButton {margin-top:10px;}

.button {
display : inline-block;
cursor : pointer;
border-radius:10px;
padding : 20px 60px;
color : #fff;
border:1px solid #ddd;
font-size:30px;
line-height:40px;
font-family: 'Oswald', sans-serif;
text-decoration : none;
}
.button.green {
background: #df3535; /* Old browsers */
background: -moz-linear-gradient(top, #df3535 1%, #9b0606 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#df3535), color-stop(100%,#9b0606)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #df3535 1%,#9b0606 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #df3535 1%,#9b0606 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #df3535 1%,#9b0606 100%); /* IE10+ */
background: linear-gradient(to bottom, #df3535 1%,#9b0606 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#df3535', endColorstr='#9b0606',GradientType=0 ); /* IE6-9 */
}

@-webkit-keyframes spaceboots {
0% { -webkit-transform: translate(2px, 1px) rotate(0deg); }
10% { -webkit-transform: translate(-1px, -2px) rotate(-1deg); }
20% { -webkit-transform: translate(-3px, 0px) rotate(1deg); }
30% { -webkit-transform: translate(0px, 2px) rotate(0deg); }
40% { -webkit-transform: translate(1px, -1px) rotate(1deg); }
50% { -webkit-transform: translate(-1px, 2px) rotate(-1deg); }
60% { -webkit-transform: translate(-3px, 1px) rotate(0deg); }
70% { -webkit-transform: translate(2px, 1px) rotate(-1deg); }
80% { -webkit-transform: translate(-1px, -1px) rotate(1deg); }
90% { -webkit-transform: translate(2px, 2px) rotate(0deg); }
100% { -webkit-transform: translate(1px, -2px) rotate(-1deg); }
}
.shake,.shake:hover,
.shake:focus {
-webkit-animation-name: spaceboots;
-webkit-animation-duration: 0.8s;
-webkit-transform-origin:50% 50%;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
}
.shake {
display:inline-block
}
.red{color:red;}
input[type=text]{
margin-top:10px;width:350px;font-size:18px;height:40px;border:1px solid #ddd;background:#fff;padding-left:5px;
}

</style>
</head>

<body>
<div id="main">
<img src="pic1.png" width="757" height="704" />
<form id="mainForm" name="frmSignUp" method="post">
    <input type='hidden' id='affiliateUsername' name='affiliateUsername' value='kusala' />
    <input type='hidden' id='campaign' name='campaign' value='6V24HI' />
    <input type='text' id='mainFormName' name='name' value='' placeholder='Your name..' /><br />
    <input type='text' id='mainFormEmail' name='email' value='' placeholder='Your email..'  />
    <br />
    <input class='shake button green' type='submit' id='mainFormSubmitButton' name='submit' value='Reserve My Spot' />
</form>
</div>
</body>
</html>

Screenshot...

016074121ff5017329d9b56beae3990f

Edited by JorgeM

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.