After the chrome 32 update, the width of the html elements (input, select,..)
defined by a css with these properties does not work:
position:absolute;
left:10px;
right:20px;
In chrome 31 and all others browsers it works.
Look at this with chrome 32
http://jsfiddle.net/EAkLb/7/
I guess this is what W3C says as the correct way of rendering input elements (I said I guess and I dindn't put the W3C spec link because I didn't found the official link for it)
A simple workarround is to create container div with the position absolute and the left and right attributes and create an input inside with width: 100%;
<div class="container">
<input type="text"/>
</div>
<style type="text/css">
.container {
position:absolute;
left:10px;
right:20px;
}
.container input {
width: 100%;
}
</style>
like in http://jsfiddle.net/pjK8s/1/
If you need to put padding than you need to style the container to looks like the input and let the input be transparent
<div class="container">
<input type="text"/>
</div>
<style type="text/css">
.container {
position:absolute;
left:10px;
right:20px;
padding: 1px 8px;
margin: 2px 0px;
-webkit-appearance: textfield;
}
.container input {
width: 100%;
border: 0px;
margin: 0px;
padding: 0px;
background: transparent;
outline: none;
}
</style>
like in http://jsfiddle.net/Vyj22/1/
Related
I'm having a problem on img:hover
Here's my jsbin: http://jsbin.com/bereputu/1/edit
My problem is when I put my mouse over the "home" or "contact", the image that I want to replace the original appears a little under than I expected.
Here's my code:
<html>
<head>
<title>UltraLotus</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="container">
<div class="header">
<img src="images/header.png">
</div>
<center>
<div class="nav">
<img src="images/home.jpg">
<img src="images/contact2.jpg">
</div>
</center>
<div class="page">
<p></p>
</div>
<div class="footer">
</div>
</div>
</body>
</html>
CSS
body {
background-image: url("images/bg.jpg");
background-repeat: repeat-y;
background-size: 100% 100%;
margin:0;
padding:0;
height:100%;
}
.container {
min-height: 100%;
}
.header {
background-color:#1a1a1a;
width:100%;
height:100px;
}
.header img {
position: relative;
margin-top:-30px;
}
.nav {
position:relative;
width:100%;
height:40px;
top: -15px;
background-image: url("images/nav.jpg");
}
.nav img {
position:relative;
margin-top:13px;
}
.nav a:first-child:hover {
position:relative;
background-image: url('images/home.jpg');
}
.nav a:nth-child(2):hover {
position:relative;
background-image: url('images/contact.jpg');
}
.page {
padding-top:5px;
top:150px;
padding-bottom:70px;
}
.footer {
position:absolute;
bottom: 0;
width:100%;
height:70px;
background-image: url("images/footer.jpg");
}
I'm not quite sure what you're looking to accomplish with the :hover styling, but it's replacing a totally different image than the one you're using in your original nav element.
For easier debugging, if you open up the chrome developer tools, you can force a hover state so you can look at all the applied css rules:
You'll notice that you're giving your a element a background-image on hover, but it's contents still contains an img element. Thus the double styling.
Note 1: Since they're both the same, you really don't even need the hover styling at all.
Note 2: This does not seem worth pulling in an image to me. You should be able to accomplish this exact style with native html an css. They render far quicker, they're much easier to download, they're much better for screen readers, they have much cleaner and clearer content, and they extend and adapt much easier. I'd skip the images altogether and go html/css for this.
Here's a little CSS to get your started:
.nav a {
color: grey;
font-size: 1.2em;
text-decoration: none;
border: 1px solid grey;
padding: 5px;
padding-bottom: 0px;
border-top-left-radius: 7px;
border-top-right-radius: 7px;
}
/* I even added in a little hover effect */
.nav a:hover {
background-color: #2C2C2C;
}
Here's your full site design without any images (except your logo):
http://jsbin.com/bereputu/2/
You can get much more sophisticated but I would avoid imaging out your design as much as possible. If you're doing web dev, learn CSS
Is there a way to turn this feature off? Contents of <button> are always vertically centered, as opposed to what happens in a regular HTML tag.
Demo: http://jsfiddle.net/HbqnR/
I want <button> behave like <a>, with the text at the top left corner of the button.
I'm looking for a WebKit specific fix, maybe there is some -webkit-* css property that controls this behavior. Hacks are welcome but without using additional markup!
Thank you in advance :)
.button
{
display:inline-block;
height:200px;
border:4px gainsboro outset;
background:silver;
vertical-align:middle;
padding:20px;
box-sizing:border-box;
text-decoration:none;
width:200px;
text-align:left;
}
<button class="button"><button></button>
<a>
Add this:
button:before {
content:'';
display:block;
margin-top:-50%;
}
See http://jsfiddle.net/r6yXw/
And, if you want it to only apply to webkit based browsers, wrap it in
#media screen and (-webkit-min-device-pixel-ratio:0) { ... }
see http://jsfiddle.net/r6yXw/1/
I see that you requested no additional markup, but if you decide to go down that route, one quick idea is to use positioning and one additional element.
button {
position: relative;
}
button > span {
position: absolute;
top: 0;
}
<button><span><button></span></button>
You can't. Not without introducing a <span> inside the <button> and use positioning:
<button class="button"><span><button></span></button>
Then add the following to .button:
.button
{
/* ... */
position:relative;
}
.button > span {
position: absolute;
top: 20px;
left: 20px;
}
Demo
If you want to keep your HTML intact, you can modify the document using JavaScript as well:
$('button.button').wrapInner('<span>');
Note that if JavaScript is disabled, it won't work :)
button {
height: 100px;
display: flex;
}
Check this out :P JSFIDDLE DEMO
.button
{
display:block;
height:200px;
border:4px gainsboro outset;
background:silver;
vertical-align:top;
padding:20px;
box-sizing:border-box;
width:200px;
text-align:left;
text-indent: 0;
white-space: normal;
word-spacing: 0px;
letter-spacing: 0px;
float: left;
top:0;
}
It might work heh. I don't really know what do you need the button for. But this gets to see just like what you were asking before.
Used it here.
<title>Documento sin título</title>
<body>
<form id="form1" name="form1" method="post" action="">
<button class="button">tODAY WE ARE HERE WONDERING WHAT TO DO<p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p></button>
</form>
</body>
Hey guys Im currently trying to get a textbox a select menu and a button all into one sized div cleanly but im running into an issue where each element has odd borders/margins which prevent it from rendering properly (the button appears below the text box and select menu)
Heres the html Im currently using
<div class="content">
<div class="search-panel">
<div class="search-panel-logo">
<img src="img.png" class="search-panel-logo-img" />
</div>
<div class="search-panel-searchbar">
<form class="search-panel-frm" action="" id="fsearchbar">
<input class="search-panel-frm" type="text" id="tseachtext" name="tsearchtext" value="Search" />
<select class="search-panel-frm" id="ssearchselect" name="ssearchselect">
<option value="Cars">Cars</option>
</select>
<input class="search-panel-frm" type="button" id="bsearchgo" name="bsearchgo" value="Search!" />
</form>
</div>
</div>
</div>
and heres the CSS:
.content {
background:inherit;
width:950px;
height:600px;
margin: 0 auto;
}
.search-panel {
width:inherit;
height:500px;
background:#093;
margin:0 auto;
}
.search-panel-searchbar {
width:inherit;
height:30px;
}
.search-panel-searchbar-frm {
width:inherit;
height:inherit;
}
.search-panel-searchbar-frm-text {
width:60%;
height:70%;
}
.search-panel-searchbar-frm-select {
width:20%;
height:80%;
}
.search-panel-searchbar-frm-go {
width:20%;
height:80%;
}
any idea what I can add to get all the elements to appear in one line as opposed to two, Ive already tried
border:0;
margin:0;
and it didnt fix the problem.
To achieve your goal, some CSS tricks had to be applied, see below the CSS:
CSS
/* wrapper */
.search-panel-searchbar {
width: 100%;
height: 30px;
overflow: hidden;
}
/* form elements must be wrapped and not a direct child of the form tag */
.search-panel-searchbar > form > div {
background-color: #fff;
width: 100%;
height:30px;
}
/* input[type="text"] */
.search-panel-searchbar-frm-text {
margin: 0;
padding: 0;
font-size: 12px;
line-height: 16px;
height: 16px; /* necessary to fix height issue on windows browsers */
padding: 6px 0;
display: block;
border: 1px solid #ccc;
background-color:#fff;
width: 60%;
text-indent: 4px;
float: left;
}
/* select */
.search-panel-searchbar-frm-select {
margin: 0;
padding: 0;
font-size: 12px;
height: 30px;
padding: 6px 4px;
display: block;
border: 1px solid #ccc;
background-color:#fff;
width: 20%;
float: left;
margin-left:-1px; /* pull to prevent border overflow issue with % */
}
/* input[type="button"] */
.search-panel-searchbar-frm-go {
margin: 0;
padding: 0;
font-size: 12px;
height: 30px;
padding: 6px 0;
display: block;
border: 1px solid #ccc;
background-color:#fff;
width: 20%;
float: left;
text-align:center;
margin-left:-1px; /* pull to prevent border overflow issue with % */
cursor: pointer;
}
Note:
CSS does not include style given on the Fiddle example to a visual demonstration, like the button hover and body background.
Please take note that unfortunately, each browser (and OS!) deals with the select in different ways, and it's likely that on one or two browsers, the style may differ.
The working Fiddle example!
Screen shot matches tests performed on:
Linux Ubuntu 12.04
Firefox 12.0
Chromium 18.0.1025.151 (Developer Build 130497 Linux)
Windows XP Profissional versão 2002 Service Pack 3
Internet Explorer 8.0.6001.18702
Opera 11.62
Firefox 3.6.16
Safari 5.1.2 (only select box height fail)
Google Chrome 18.0.1025.168 m
K-Meleon 1.5.4 (fail due to font-family)
Windows 7 Home Edition Service Pack 1
Internet Explorer 9.0.8112.164211C
Opera 11.62
Firefox 12.0
Safari 5.1.4
Google Chrome 18.0.1025.168 m
The font-family that you will use must contain a font family declaration at the end to prevent line-height and text-size issues. e.g., font-family: Helvetica, Arial, sans-serif
Remove the whitespace between the elements.
Also, using width: inherit is probably not a good idea - try width: 100% instead or something along those lines. height: inherit can be replaced with height: auto; (or just omitted).
You've posted some CSS classes that doesn't apply to the HTML you posted (eg. .search-panel-searchbar-frm-go)
You're applying the class search-panel-frm to your form element as well as elements within the form. Are you sure this is what you want?
I'm not seeing the same problem: The input, select and input:button all appear on the same line for me.
You can try adding this simple fix to keep everything on one line which may give you some ideas.
.search-panel-frm *
{
white-space:nowrap;
}
If all your elements are already on the same line and you want them to line up better try different values for vertical-align, such as:
.search-panel-frm *
{
vertical-align:top;
}
I'm trying to remove all effects on a HTML Button element.
The HTML:
<div id="go">
<button onclick="load.update(true,cards.id);" type="submit"></button>
</div>
The CSS:
#header #go button{
display:block;
border:0 none;
cursor:pointer;
outline:none;
vertical-align:top;
width:18px;
height:33px;
background:url('../images/cards/go.png'); //Just an image to replace it all.
}
In Chrome and Firefox this works fine, but in IE (8 at least) the "push" effect of the button is still there when the button is clicked (EG the offset)
Is there any Tricks i can use to remove this effect?
Thanks in advance!
Diesal.
you need to add background styles to :hover :active :focus as well.
#header #go button:hover {
border: none;
outline:none;
padding: 5px;
background:url('../images/cards/go.png');
}
#header #go button:active {
border: none;
outline:none;
padding: 5px;
background:url('../images/cards/go.png');
}
#header #go button:focus {
border: none;
outline:none;
padding: 5px;
background:url('../images/cards/go.png');
}
I had a similar experience, and was able to fix it in IE8, but not IE7. See it working here:
http://jsfiddle.net/GmkVh/7/
HTML:
<button></button>
CSS:
button {
color:#fff;
background:#000;
border: none;
outline:none;
padding: 5px;
cursor: pointer;
height: 25px;
}
/*
It hits this state (at least in IE) as you're clicking it
To offset the 1px left and 1px top it adds, subtract 1 from each,
then add 1 to the right and bottom to keep it the same width and height
*/
button:focus:active {
padding-top: 4px;
padding-left: 4px;
padding-right: 6px;
padding-bottom: 6px;
color: #ccc;
}
One way would be to get rid of the <button> tag completely and use a <a href=".." /> tag in its place styled the way you want.
Just have the link do a javascript postback.
update (from comments):
one example:
Click Here
Of course, this requires javascript to be enabled and is considered by some to be an abuse of the anchor tag.
There are alternate versions if you are using .net webforms or jQuery.
After you have done whatever you like with the border etc., just put a span inside the button around the text like so:
<button class="button" type="submit"><span class="buttonspan">Blah</span></button>
Then the CSS becomes:
button {position:relative; width:40px; height:20px /* set whatever width and height */}
buttonspan {
height: 30px;
left: 0;
position: absolute;
top: 0;
width: 100%;
}
<div class="calculation_button">
<button type="submit"><span>Count</span></button>
</div>
.calculation_button span {
position: relative;
left: 0;
top: 0;
}
works for me in IE and FF
The following helped for me in IE 10:
button:active {
position: relative;
top: -1px;
left: -1px;
}
It fixed the top perfectly, but left still had background bleed-though for my case. Still looks a bit odd if the user starts clicking and then moves the mouse off the button. Also obviously only enable the rule for relevant IE version(s).
Position relative seemed to have taken care of the problem
Simply have a wrapper within the button:
So
<button>
<div class="content">Click Me</div>
</button>
and set the DIV to position relative with top: 0, left: 0
Example below:
http://jsfiddle.net/eyeamaman/MkZz3/
It's a browser behaviour, a simple solution is to use a link tag instead of button (since you're calling a javascript function).
<img src="myimg"/>
If you still want to use the , I've found that there are some characteristics on each browser (in a simple debug):
Chrome adds outline and padding
Firefox adds a whole lot of stuff with the standart button border
IE messes with the inner text position
So to fix them, you have to manipulate the pseudo selectors for the button behaviour. And for IE, a good solution is to envolve your text on a element, and make it relative positioned. Like so:
<button type="button" class="button"><span>Buttom or Image</span></button>
<style>
button,
button:focus,
button:active{
border:1px solid black;
background:none;
outline:none;
padding:0;
}
button span{
position: relative;
}
</style>
Pen
This is a duplicate question
I have a text input with a search buton absolute positioned over it... to make space for the button I used some padding to keep the text from going under the button, which is fine, it works in firefox, but not IE.
In fact... It doesn't seem like padding on text inputs works at all in IE.
They have the following code
<style type="text/css">
#mainPageSearch input {
width: 162px;
padding: 2px 20px 2px 2px;
margin: 0;
font-size: 12px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
background:#F3F3F3 url(form-shadow.png) repeat-x scroll left top;
border-color:#C6C6C6 #C6C6C6 #E3E3E3;
border-style:solid;
border-width:1px;
color:#666666;
}
#mainPageSearch {
margin-bottom: 10px;
position: relative; /* Lets me absolute position the button */
}
#mainPageSearchButton {
display: block;
position: absolute;
top:0px;
right: -2px;
text-indent: -2000em;
height: 22px;
width: 22px;
background: transparent url('images/searchBtn.png') top center no-repeat;
}
</style>
<form id="mainPageSearch" action="">
<input type="text"/>
<a id="mainPageSearchButton" href="#">Search</a>
</form>
Is what I'm trying to do possible or should I just suck it up and deal with the text going under the search button?
I know I could make a search box with a transparent background/border and draw the styling using a containing div... but that isn't really an option because of how many places I've have to change it on the site.
Maybe I'll make a new class for this text input that makes it transparent and assign the normal text input style to the containing div? What do you think?
edit: sorry I should have included the doctype... here it is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
also, The problems I'm having are in IE 7
try using line-height
I had this issue also i solved it by adding the following line
input
{
overflow:visible;
padding:5px;
}
hope this helps? Let me know.
Try border-right instead of padding-right. This worked for me.
Make your input transparent and place styles inside a container div:
http://jsfiddle.net/LRWWH/211/
HTML
<div class="input-container">
<input type="text" class="input-transparent" name="fullname">
</div>
CSS
.input-container {
background:red;
overflow:hidden;
height: 26px;
margin-top:3px;
padding:6px 10px 0px;
width: 200px;
}
.input-transparent {
background-color:transparent;
border:none;
overflow:hidden;
color:#FFFFF;
width: 200px;
outline:none;
}
There is a css only fix for it
div.search input[type="text"] {
width: 110px;
margin: 0;
background-position: 0px -7px;
text-indent:0;
padding:0 15px 0 15px;
}
/*ie9*/ div.search input[type="text"] {
border-left: 25px solid transparent;
}
/*ie8*/ div.search input[type="text"] {
border-left: 25px solid transparent;
background-position-x: -16px;
padding-left: 0px;
line-height: 2.5em;
}
Thanks
Muhammad Atif Chughtai
You'll have to use float: left/right on '#mainPageSearch input' before you can apply padding/margin.
I experienced a similar problem - IE was padding the input field, but not making it bigger, thus pushing the text down inside of it. I fixed it by setting the height of the input as well. Try that.
I have the following working in IE7. What version are you targeting?
<style type="text/css">
input#test {
padding: 10px;
}
</style>
<input type="text" id="test" />
What about declaring DOCTYPE?
By adding <!DOCTYPE html> padding works grand for me in IE8. Take the following code as an example:
<!DOCTYPE html>
<html>
<head>
<style>
#myInput {
padding: 10px;
}
</style>
</head>
<body>
<input id="myInput" value="Some text here!" />
</body>
</html>