Submit button not cooperating - html

I am sure this is a complete oversight on my part, but I have a button I would like to the immediate right of an input box, my html is:
<input type="text" name="q" id="search" />
<input type="submit" name="submit" id="submit" value="Go!" />
and css is:
#main input {
margin: 30px auto auto 130px ;
positiom: absolute;
font-size: 18px;
background: #fff;
border: 3px;
padding: 6px;
z-index: 3;
}
#search {
float: left;
width: 550px;
}
#submit {
width: 60px;
}
#submit::-moz-focus-inner {
border: 0;
padding: 0;
}
The Go! button just sits directly below the left side of the submit box and any kind of margin tweaking is in vain bc it just stays there. Also tried making the position absolute and the button overlaps.
The Go! button will not position correctly - it is supposed to be to the right of my input box but it hangs below it instead.
How can I get it to position directly to the right my input box?
Thanks for any help!
EDIT:
html{
background: url(images/bg5.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
#main{
width: 875px;
height: 350px;
background: url(images/form3.png) 0 0 no-repeat;
margin:250px auto;
z-index: 1;
}
#main form {
width: 850px;
height: 191px;
background: url(images/logo3.png) 0 0 no-repeat;
margin: -165px auto auto -90px;
position: absolute;
z-index: 2;
}
#text {
font-size: 30px;
color: #ffffff;
font-family: parisjetaime;
margin: 189px auto auto 130px ;
line-height: 30px;
}
#main input {
margin: 30px auto auto 130px ;
font-size: 18px;
background: #fff;
border: 3px;
padding: 6px;
z-index: 3;
}
#search {
width: 550px;
}
#submit {
width: 60px;
float: right;
}
#submit::-moz-focus-inner {
border: 0;
padding: 0;
}

Not sure if this is where your problem is, but it seems that by taking out margin: 130px auto auto 200px ; from #submit the Go! button is properly placed on the right of the search box.
Demo:
http://jsfiddle.net/3ykRD/
Edit
Solution: http://jsfiddle.net/H3gYM/1/
The #main input properties were overriding the #submit properties - in this case the margins are what made the Go! button be displaced. Placing !important cancels the override and then tweaking the margins fixed the problem.

Why absolutely position your inputs? Here is a slightly trimmed down code which will put them next to each-other. The float:left was causing the height dis-joint because it causes the two elements to no longer be in the same 'line'
#main input {
font-size: 18px;
background: #fff;
border: 3px;
padding: 6px;
z-index: 3;
}
#search {
width: 550px;
}
#submit {
width: 60px;
}
#submit::-moz-focus-inner {
border: 0;
padding: 0;
}

I think what you want is to place the button just right to the text box, right? If so You need to float the input button and the textbox to left too;
#textbox {
float: left;
}
#submit {
width: 60px;
float: left;
}
This always work for me :) Let me know if it worked!

Related

How to place a button over a shape in CSS?

I am creating a website with a login and sign in feature, and want to place the buttons over a solid dark blue background above the gradient but below the buttons. When I try to create a shape, the buttons move down on the website to accommodate room for it, but I want the shape to be on a layer below the buttons but still visible. Is there any way of doing this in CSS?
If so, how? Thanks :)
Here is my CSS and HTML so far:
HTML:
html {
height: 100%;
background-size: cover;
background: #a5fcff;
background-repeat:no-repeat;
background: linear-gradient(#00033a, #a5fcff);
}
.signinbutton {
background-color: #458af9;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
display: block;
font-size: 75px;
margin: 4px 2px;
cursor: pointer;
transition-duration: 0.5s;
margin-left: auto;
margin-right: auto;
margin-top: 225px;
}
.signinbutton:hover {
background-color: #a7acb7;
}
.createaccbutton {
background-color: #458af9;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
display: block;
font-size: 75px;
margin: 4px 2px;
cursor: pointer;
transition-duration: 0.5s;
margin-left: auto;
margin-right: auto;
margin-top: 100px;
}
.createaccbutton:hover {
background-color: #a7acb7;
}
<html>
<head>
<title>Debate Website</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class = "square"></div>
<button class = "signinbutton">SIGN IN</button>
<button class = "createaccbutton">SIGN UP</button>
</body>
</html>
UPDATE:
Sorry, I want the website screen to look like this:
Login Screen mock-up
But it currently looks like this:
Actual login screen so far
Use position: absolute; as mentioned above. If you end up with something on top of another (covering up the thing underneath) then you can use z-index: [number]; to specify what is on top of what.
You can position the element absolute relative to the html or another container.
example style:
.square {
position: absolute;
top: 0;
margin-left: auto;
height: 200px;
width: 200px;
background: #f00;
margin-right: auto;
left: 0;
right: 0;
}
Working example
1) First, edit your html, body style.
html {
height:100%
}
body {
background: #a5fcff;
background: linear-gradient(#00033a, #a5fcff); /* background first, followed by the other options */
background-size: cover;
background-repeat:no-repeat;
background-attachment: fixed /* for repeating gradient */
}
2) Customize .square element if you want.
.square {
position: absolute;
top:0; /* above the gradient */
left:0;margin-left:auto;right:0;margin-right:auto; /* center position:absolute element */
height: 200px;
width: 200px;
background: #0000ff
}
4) Add one margin line for buttons and remove others.
.signinbutton {
margin: 225px auto 0 auto; /* 225px for top, auto for right&left, 0px for bottom */
}
.createaccbutton {
margin: 100px auto 0 auto; /* 100px for top, auto for right&left, 0px for bottom */
}

"margin: 0 auto" doesn't work when width is defined

I was creating a search tool for my website, and i wanted it to be in center, So i created main div container that would hold every search tool element, which had margin: 0 auto and it worked. But inside it another element which had margin: 0 auto; would not be centered.
HTML:
<div class="searchbox">
<div class="mover">
<input type="text" name="searchfield" class="search" placeholder="Search Item">
CSS:
.searchbox {
position: absolute;
width: 100%;
overflow: hidden;
left: 0%;
top: 55px;
height: 350px;
background-color: black;
}
.mover {
display: block;
z-index: 2;
background-color: white;
margin: 0 auto;
width: 70%;
height: 100%;
min-width: 600px;
height: 250px;
}
.search {
position: relative;
width: 70%;
height: 35px;
top: 100px;
margin: 0 auto;
border: solid 1px black;
border-radius: 7px;
}
.search[type=text] {
color: black;
text-align: center;
font-family: 'Lato';
font-size: 15px;
}
Please note that i do not want width: 100% for search element, as you see in code, i have min-width: 600px defined, which is for other elements in mover which is not relevant in this case.
Please check out, Fiddle
What could the problem be? I have defined width on both elements, but margin auto still doesn't work, is there any way to fix this?
The <input> is an inline-level element, the margin: auto tricks only works for block level elements.
You can do:
.search {
...
width: 70%;
margin: 0 auto;
display: block; /*add this line*/
}
Or, if you prefer leave it as inline you can do:
.mover {
text-align: center;
}

How can I get my divs to stay in place?

I'm working a friend's site: http://www.lauraradniecki.com and I'm trying to get the newsletter bar to stay aligned with the body text, even when the browser is resizing. This works fine, if you're scaling down in size, but if you go up, the size between the text and the subscribe box starts to move away from each other. I can't figure out how to get this fixed
#inside {
margin-left: 11%;
max-width: 530px;
font-size: 100%;
float: left;
}
#insideright {
float: right;
margin-right: 12%;
}
#insideright .formsubmit {
margin: -1px 3px 1px 16px;
}
#subscribe {
background-color: #7EBFC5;
color: #fff;
padding: 30px 30px 40px;
height: 100% !important;
overflow: hidden;
}
Sorry if that's confusing- it's my first time posting here.
I would put the newsletter bar text in a container that is the same size as the body text container. Then set the left and right margins just the same as the body text containers.
Essentially you would make a smaller version of the main content container inside itself.
Assuming from your explanation and code the inside styles should be IN the subscribe id...
#inside {
margin-left: 11%;
max-width: 530px;
font-size: 100%;
left: 0px;
position: absolute;
}
#insideright {
right: 0px;
margin-right: 12%;
position: absolute;
}
#insideright .formsubmit {
background: #ccc;
position: absolute;
right: 0px;
}
#subscribe {
background-color: #7EBFC5;
color: #fff;
padding: 30px 30px 40px;
height: 100% !important;
overflow: hidden;
}

Line-height not precisely centers vertically with Chrome

<div id="submitHolder">
<input type="submit" value="">
</div>
#submitHolder {
background-color: #FF0000;
line-height: 124px;
text-align: center;
}
input[type="submit"] {
background-image: url("http://icons.iconarchive.com/icons/hopstarter/button/256/Button-Next-icon.png");
background-position: 0 0;
background-repeat: no-repeat;
border: 0 none;
height: 44px;
width: 194px;
}
http://jsfiddle.net/BLPE7/4/
as you can see, it is precisely centered vertically with firefox, but not with chrome. How to solve it?
That problem seems to occur because your submit button has an empty value – looks like chrome messes something up with the line-height then. Once I give it a value, and if it’s even just a space character (and therefor still not visible), the problem disappears:
<input type="submit" value=" ">
http://jsfiddle.net/BLPE7/9/
You can also use padding. Check this out: http://jsfiddle.net/tDj2U/1/
#submitHolder {
background-color: #FF0000;
/*line-height: 124px;*/
padding: 40px 0;
text-align: center;
}
input[type="submit"] {
background-image: url("http://icons.iconarchive.com/icons/hopstarter/button/256/Button-Next-icon.png");
background-position: 0 0;
background-repeat: no-repeat;
border: 0 none;
height: 44px;
width: 194px;
}
Yes, there is such problem for chrome with big line-height values. I solve this problem in your case by adding position absolute/relative and margin centering:
#submitHolder {
background-color: #FF0000;
height: 124px;
text-align: center;
position: relative;
}
input[type="submit"] {
background-image: url("http://icons.iconarchive.com/icons/hopstarter/button/256/Button-Next-icon.png");
background-position: 0 0;
background-repeat: no-repeat;
border: 0 none;
height: 44px;
width: 194px;
position:absolute;
left: 50%;
top: 50%;
margin: -22px 0 0 -97px;
}
http://jsfiddle.net/BLPE7/11/
Add vertical-align:middle to your input control.

How to squash a div vertically and keep element below 100% on screen

So I have this code here: http://jsfiddle.net/nUwgX/ which has a little arrow at the bottom. What I'd like to happen is when the window get's resized is to keep the arrow about 15% from the bottom of the screen but I'm not sure how I'd do that. Any help would be appreciated.
HTML:
<div class = "container">
<div class = "top-wrapper">
<a id = "name" href = "#">Bigfoot Games</a>
</div>
<div class = "bottom-wrapper">
<p>Content</p>
</div>
</div>
CSS:
.container {
width: 100%;
height: 100%;
margin: 0 auto;
position: relative;
padding: 0;
text-align: center;
}
.top-wrapper {
position: relative;
background: #0f0f0f;
height: auto;
height: 100%;
max-height: 900px;
width: 100%;
margin: 0 auto;
padding: 0;
display: table;
}
.top-wrapper:after {
top: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(15, 15, 15, 0);
border-top-color: #0f0f0f;
border-width: 30px;
margin-left: -30px;
}
#name {
display: table-cell;
text-align: center;
vertical-align: middle;
padding: 20px;
color: white;
font-size: 80px;
text-decoration: none;
margin: auto 0;
}
.bottom-wrapper {
background: white;
margin: 0 auto;
padding: 20px;
}
Edit: Okay, so saying that I wanted the arrow about 15% above is not what I meant! Ha! What I mean is, I want the .top-wrapper to be 100% so that it covers the whole window, and you scroll down to see the .bottom-wrapper - however when the screen is resized (other than my 1920 x 1080 resolution) the arrow get's hidden just out of sight, what I'd like is the arrow to be visible regardless of resolution and have the look (in terms of padding/distance) as a 1920 x 1080 resolution.
Change the css of .top-wrapper to only take up 85%, that leaves 15% for the "arrow" on the bottom to take up.
.top-wrapper {
...
height: 85%;
...
}
see the jsfiddle:
http://jsfiddle.net/nUwgX/1/
Change your .top-wrapper height to 85%
I changed just that in the jsfiddle and it maintains when the screen is resized. If that isn't what you are looking for, please elaborate on the question.
Good Luck!
If you want to keep your bottom-wrapper at the bottom fixed position ...
Replace your .bottom-wrapper class with below
.bottom-wrapper {
position:fixed;
bottom: 0px;
height: 15%;
width: 100%;
background-color: white;
margin: 0 auto;
}
.bottom-wrapper p{
padding-top: 20px;
}
Then change .top-wrapper:after to .bottom-wrapper:before