<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.
Related
I have a background image that's about 1200 (w) x 800 (h) but i just want to use the whole 100% resolution for it. I have a button inside this div container but it's not displaying correctly. The background image won't expand to it's full resolution. It seems like it's only showing enough to allow the button to show.
.endFoot {
background-image: url('https://via.placeholder.com/900x900');
background-size: cover;
width: 100%;
height: 100%;
}
.customButton {
position: relative;
bottom: 0;
left: 41%;
padding: 25px 35px;
font-size: 16px;
cursor: pointed;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #AB0002;
border: none;
border-radius: 15px;
}
<div class="endFoot">
<button class="customButton">TEXT</button>
</div>
here's a little picture demonstrating what's going wrong vs what i want:
This has nothing to do with background image not expanding. Your div is simply not tall enough to show more of the image. Going off of your diagram, you want to add some padding to .endFoot.
background-size: cover; is a good choice, but you may also want to consider centering the position with background-position: 50% 50%;.
.endFoot {
background-image: url('https://via.placeholder.com/900x900');
background-size: cover;
background-position: 50% 50%;
width: 100%;
background-repeat: no-repeat;
padding: 400px 0 0 0;
height: 100%;
}
.customButton {
position: relative;
bottom: 0;
left: 41%;
padding: 25px 35px;
font-size: 16px;
cursor: pointed;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #AB0002;
border: none;
border-radius: 15px;
}
<div class="endFoot">
<button class="customButton">TEXT</button>
</div>
If you would like the endFoot div to have the same height as the background, just set the height to 800px, because 100% doesn't change anything in this case.
Also set the endFoot position to relative in order to put the botton to the correct position.
If you are trying to achieve full screen background try :
.endFoot {
width: 100vw;
height: 100vh;
}
For browser support informations of vh and vw units check : https://caniuse.com/#feat=viewport-units
Just add text-align:center to .endFoot class to make center button and add some margin to .customButton class for leave some space to bottom.
.endFoot {
background-image: url('https://via.placeholder.com/900x900');
background-size: cover;
background-position: 50% 50%;
width: 100%;
background-repeat: no-repeat;
padding: 400px 0 0 0px;
height: 100%;
position: relative;
text-align: center;
}
.customButton {
padding: 25px 35px;
font-size: 16px;
cursor: pointed;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #AB0002;
border: none;
border-radius: 15px;
margin-bottom: 10px;
}
<div class="endFoot">
<button class="customButton">TEXT</button>
</div>
I want to use prop line-height and height center vertically a text input in one div.
Below is the less code snippets:
div.header {
background-color: #6283E6;
height: 70px;
line-height: 70px;
min-width: 1220px;
input.search-input {
border: none;
border-radius: 16px;
background-color: #C9D4F6;
background-image:url('../assets/search.png');
background-repeat: no-repeat;
background-position: 14px, center;
height: 30px;
width: 353px;
padding-left: 49px;
}
}
But the actual effect in chrome is in below:
So why this happened.
Can you tell me?
Below is my Jsx code, Header has only one parent node and this node is the root node.
class Header extends React.Component {
render() {
return (
<div className={style.header}>
<input type="text" className={style['search-input']} />
</div>
);
}
}
I tested your code, and it seems fine to me:
div.header {background-color: #6283E6;
height: 70px;
line-height: 70px;
min-width: 1220px;
}
input.search-input {
border: none;
border-radius: 16px;
background-color: #C9D4F6;
background-image:url('../assets/search.png');
background-repeat: no-repeat;
background-position: 14px, center;
height: 30px;
width: 353px;
padding-left: 49px;
}
<div class="header">
<input type="text" class="search-input">
</div>
There must be something else wrong in code that you didn't show us.
Remember div and input have default margin and padding, so set margin and padding to 0 for both.
Alternatives:
Instead of fixing the height, you can use padding on the top and bottom.
You can use flex.
Encountering a CSS push down problem, been searching for fix but not able to find out what exactly is the problem. All the icons are displayed in a stairs-like layout. Need your help in fixing this.
HTML
<div style="/*float: left; width:153.6px;" */ class="footerStyles">
<h4 style=" margin: 0; font-size: 100%;">CONNECT</h4>
<br/>
<br/>
<br/>
<div class="clear"></div>
</div>
CSS
.connectWith{
/*background-position: left center;
background-repeat: no-repeat;
padding-top: 8px;
padding-bottom: 8px;
padding-left: 40px;*/
margin-right: 0;
padding: 0;
float: left;
}
/* email ---------- */
.email{
width: 50px;
height: 50px;
text-decoration: none;
display: block;
text-indent: -9999px;
background-image: url("http://www.browsealoud.com/images/browsealoud/plus/uk/firefox.jpg");
background-position: 0 0;
}
.email:hover{
background-position: 0 50px;
}
/* twitter ---------- */
.twitter{
width: 50px;
height: 50px;
text-decoration: none;
display: block;
text-indent: -9999px;
background-image: url("http://www.browsealoud.com/images/browsealoud/plus/uk/firefox.jpg");
background-position: 0 0;
}
.twitter:hover{
background-position: 0 50px;
}
/* facebook ---------- */
.facebook{
width: 50px;
height: 50px;
text-decoration: none;
display: block;
text-decoration: -9999px;
background-image: url("http://www.browsealoud.com/images/browsealoud/plus/uk/firefox.jpg");
background-position: 0 0;
}
.facebook:hover{
background-position: 0 50px;
}
/* google+ ---------- */
.googleplus{
width: 50px;
height: 50px;
text-decoration: none;
display: block;
text-decoration: -9999px;
background-image: url("http://www.browsealoud.com/images/browsealoud/plus/uk/firefox.jpg");
background-position: 0 0;
}
.googleplus:hover{
background-position: 0 50px;
}
JSFiddle
If you want them side-by-side, then you should remove the <br />s you have. That's what's causing the stair effect.
http://jsfiddle.net/HZ4UU/1/
If you want them to display one underneath the other, then you shouldn't have it floated at all.
You just need to include property clear:both (or left, right).
Take out <br> element after each <a> tag and your problem will vanish. You are floating a elements left, but they are also separated with <br> tags that have some default margin and padding.
The search glass icon in the orange input at the top of my page here isn't displaying as a link, so when hovered over the pointer doesn't show.. Any ideas why it might be?
Here's the CSS:
.searchGlass {
background-image: url(/images/searchicon.png);
background-position: left 1px;
background-color: rgba(0, 0, 0, 0);
display: block;
height: 18px;
position: relative;
top: -24px;
width: 15px;
background-repeat: no-repeat;
left: 7px;
}
.hideText {
text-indent: 125%;
white-space: nowrap;
overflow: hidden;
}
.submit {
margin: 1em 0 0 0;
width: 30px;
height: 30px;
text-transform:uppercase;
font-size:15px;
padding: 6px 13px;
cursor:pointer;
border-radius: 20px;
}
And html:
<div class="left"><input type="submit" class="submit hideText" value=""/><span class="searchGlass hideText">Go</span></div>
Many thanks.
Try from here:
<div class="left">
<button class="submit"><span class="searchGlass hideText">Go</span></button>
</div>
and CSS:
.searchGlass {
background-color: transparent;
background-image: url("/images/searchicon.png");
background-position: left 1px;
background-repeat: no-repeat;
display: block;
height: 18px;
position: relative;
width: 15px;
}
You can always submit by javascript:
<span class="searchGlass hideText">Go</span>
the default display for span is inline, you have to change it to block then float it where you want, then you will be able to but width and height
try this in CSS
.hideText {
text-indent: 125%;
white-space: nowrap;
overflow: hidden;
width:50px; /* 50px is just assumed value, put yours */
height:50px;
display:block
float:left;
}
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!