I have a strange CSS issue, I'm not quite sure how to fix this.
When I press the "Sign In" button on my website and I start to type in the Username, the header goes up. I really don't know what is causing this.
Any ideas?
Thanks!
Here is some code:
The form:
.tooltip-wrap {
position: fixed;
display:none;
}
.tooltip-wrap .corner {
position:relative;
z-index:100;
margin-left:-5px;
width:0;
height:0;
border:5px solid transparent;
border-bottom-color:#fff;
}
.tooltip-text {
float:left;
margin-left:-50%;
padding:1em 15px;
background:#fff;
color:#333;
}
This is the part that goes up:
.header-navigation.back {
z-index:-1;
position:absolute;
margin-left:0;
margin-top:-6px;
border:none;
display:block; height:137px; width:1171px; padding:0px; outline:none; text-indent:-9999px;
background-image:url('xhttp://frenchegg.com/images/backmenu.png');
}
You need to click on Username and start typing something.
Very strange bug, and I can't explain what's going on. But it is related to your div.header-navigation.back. If you remove that, the behaviour disappears.
As far as I can tell, you are only using that element for your background image, so it's not a good idea to include it in the markup anyway. If you amend your .site-header you can achieve the same effect without the extra div:
.site-header {
background: #0894ff url('http://frenchegg.com/images/backmenu.png') 50% 20px no-repeat;
background: url('http://frenchegg.com/images/backmenu.png') 50% 20px no-repeat,
linear-gradient(to bottom, rgba(255,255,255,0.1) 0%,rgba(255,255,255,0) 100%);
}
I couldn't quite work out what you're trying to achieve with your gradient, but the idea would be to provide multiple backgrounds for those browsers that support them, with a fallback to a solid colour.
Change the line-height of the input box - fixes the issue.
HTML to change:
<input type="text" id="text-user" name="user_login" value="Username" style="
line-height: 15px;
">
CSS:
#text-user{
line-height: 15px;
}
The reason is because the line-height of the input was much smaller without text, than it was with text. So when you typed something into the box, the line-height expanded which is what caused the header to be pushed up.
Edit
I see you're having no luck with the code, so do these two more things and you're sure to be up and running - it's working here for me.
Remove the following from .site-header:
padding: 2em 0;
Next, change the row style to look like this:
.row{
margin: 0 auto;
padding: 0 30px;
width: 1171px;
height: 137px;
}
I think the solution is along these lines:
Set .header-wrap to have overflow:visible (well, remove overflow hidden!) - this will mean you have to slice those character graphics to have flat bottoms.
Then, change .tooltip-wrap to be position:absolute;z-index:2; (not fixed).
I also noticed that you have the placeholder polyfill in your head. This means you could use that attribute on the input rather than value; like so:
<input type="text" name="user_login" placeholder="Username">
Very cute site!
You could give it a z-index instead of a fixed position, and give it an absolute position.
Related
This one is going to be very specific I guess... My CSS works flawlessly on all browsers exept IE8. EI10's IE8 emulation does not reflect this bug.
Here is my CSS line that causes problem:
.flag{
display:block;
width:24px;
height:16px;
background-image:url('../img/flags_sprite.png');
background-repeat:no-repeat;background-position:0 0;
}
Note that this CSS part is condensed on a single line in production like so:
.flag{display:block;width:24px;height:16px;background-image:url("../img/flags_sprite.png");background-repeat:no-repeat;background-position:0 0}
The width is not taken into consideration by the browser, when inspecting the Styles parsed by the browser I can see this:
.flag
background-image: url(../img/flags_sprite.png); WIDTH: 24px
display: block
background-repeat: no-repeat
background-position: 0px 0px
height: 16px
Notice that the width is lost as it is treated as part of the background-image declaration. I am mesmerized by this, seeing that the width declaration is textually before the background-image in the CSS file...
What are my options here?
I saw that some time ago, solution that worked for me was to write background definition in single line:
background: url("../img/flags_sprite.png") no-repeat 0 0;
Another idea is to split definition of .flag into 2 parts, also works for me:
.flag{
display:block;
width:24px;
height:16px;
background-repeat:no-repeat;
background-position:0px 0px;
}
.flag{
background-image:url('../img/flags_sprite.png');
}
Another solution I ran into is to define all 5 background-xxx properties (-color, -image, -repeat, -position, -attachment). Lack of any cause problem. Example:
.flag{
background-color: transparent;
background-image:url('../img/flags_sprite.png');
background-repeat:no-repeat;
background-position:left top;
background-attachment: fixed;
display:block;
width:24px;
height:16px;
}
I have a small issue trying to get the following to work, and am not sure if it is something that CSS3 is designed to deal with or not. I have looked around and found that multiple background images are supported, however trying the many examples have resulted in nada.
This is the primary CSS code for rendering my buttons:
.button {
background:#eee url(images/button.gif) repeat-x 0 0;
border:solid 1px #b1a874;
color:#7f7f7f;
font-size:11px;
padding:2px 6px 2px 6px;
cursor:pointer;
line-height:14px !important;
}
The above code produces the standard buttons which are fine. But now I want to add icons on certain buttons, such as a print button. I use 2 sets of additional CSS class:
input.addImage {
background-repeat: no-repeat; /* once */
background-position: 5px 2px;
padding-left: 16px;
vertical-align: middle;
}
And:
input.Print {
background-image: url(../img/buttons/print.png); /* 16px x 16px */
}
As you can see my image is in fact 16x16 which fits nicely into the buttons. However the original background image is stripped away completly, leaving the background color as transparent.
I am sure that if its possible, its something basic I am overlooking, and look forward to figuring this out.
Finally the code for the button:
<input type="button" class="button addImage Print" ... >
Thank you for your valuable time.
When you apply a property in CSS, it completely overwrites any previously defined property for that element. What you need to do is tell it to apply 2 backgrounds to the element, which is done like this:
.button.Print {
background-image: url(images/button.gif), url(../img/buttons/print.png);
}
Multiple backgrounds is only supported within the same CSS class / element definition. Means, you have to set both backgrounds in .button.
Your .print has to contain the default background too seperated by a comma and followed with your print.png icon.
edit
My answer wasn't really clear about that. you have to specify the background first, which should be on top of the other one. Here's some example code with random pictures.
Demo: http://jsfiddle.net/RzWfp/
.button {
background-image: url(http://www.myinkblog.com/wp-content/uploads/2009/02/background2.jpg);
border:solid 1px #b1a874;
color:#7f7f7f;
font-size:11px;
padding:2px 6px 2px 6px;
cursor:pointer;
line-height:14px !important;
}
.button-test {
background-image: url(http://www.famfamfam.com/lab/icons/silk/icons/feed.png), url(http://www.tutorial9.net/wp-content/uploads/2008/07/air-balloon-gradient.jpg);
background-position: left center, center center;
background-repeat: no-repeat;
padding-left: 20px;
}
I have an image on a page and when I hover the image should show a different color. The hover itself works but the original image is on top of the hover image. I have tried setting z-index but does not work correctly.
Here is the CSS:
#login, #logout {
float:left;
padding: 0px 10px;
margin-left:5px;
margin-top:15px;
z-index:1;
}
#login:hover{
background:transparent url('../images/skin/loginhover.png') no-repeat 0px 0px;
float:left;
padding: 0px 10px;
margin-left:15px;
margin-top:15px;
z-index:10;
}
#logout:hover{
background:transparent url('../images/skin/logouthover.png') no-repeat 0px 0px;
float:left;
padding: 0px 10px;
margin-left:15px;
margin-top:15px;
z-index:10;
}
Thanks for any help and advice!
May I suggest you use CSS sprites instead. I believe they are a much more efficient method of achieving what you want.
Rather then 're-inventing the wheel' and writing how to do it here have a look at http://sixrevisions.com/css/css-sprites-site-speed/ or just google 'CSS Sprites'.
They decrease HTTP requests and therefore amount of bandwidth your site uses.
Hope that helps. If not, comment and i'll try and come up with a better option.
Cheers,
Matthew
You're better off having the original image and the hover state on the same element. Right now, the original is an image contained within the link tag, so it is on top.
Do this
Remove the image
Add this CSS to #login
background: url("../images/skin/login.png") top left no-repeat;
display: block;
height: 26px;
width: 80px;
It's better to have both images on the same image (a sprite), and just change the background position on hover. This eliminates flashing as the image loads upon first hovering. See the other answer by Matthew about that.
remove the hover css and change the image to this:
<img height="26" width="80" alt="LOGIN" src="/images/skin/login.png" onmouseover="switchImageIdOver(this,'../images/skin/loginhover.png');" onmouseout="switchImageIdOut(this,'/images/skin/login.png'); />
and add this script to your page:
function switchImageIdOver(elem, imgPath) {
elem.src = imgPath;
}
function switchImageIdOut(elem, imgPath) {
elem.src = imgPath;
}
If you are like me and don't like using sprites:
I came up with a quick and easy way to have the same effect (image fade to color) the only drawback is you need a transparent PNG, but works great with lots of buttons or social media icons.
HTML:
<div class="facebookicon">
<img src="http://example.com/some.png">
</div>
CSS:
.facebookicon img {
background: #fff;
transition: background 400ms ease-out;
}
.facebookicon img:hover {
background: #3CC;
transition: background 400ms ease-in;
}
/* you need to add various browser prefixes to transition */
/* stripped for brevity */
Let me know if you like it.
The default weight of 1px for line-through property in CSS is great for body copy at 1em.
Unfortunately for larger items such as a price set at 3em on an offer site, 1px is really too light. Is it possible to set a heavier line weight for line-through?
If not, what alternatives should I consider, such as an image overlay for example?
You can do something like this in modern browsers
.strike{
position: relative;
}
.strike::after{
content: '';
border-bottom: 4px solid red;
position: absolute;
left: 0;
top: 50%;
width: 100%;
}
I <span class="strike">love</span> hate hotdogs
Made a fiddle of it too:
http://jsfiddle.net/TFSBF/
Here's another way to do it with a fake strike-through (which looks great and works on all browsers, albeit with the cost of a tiny imageload). The image is a black 1px by 2px box.
del {
background: url(/images/black-1x2.png) repeat-x 0 10px;
}
I think this is a browser implementation issue.
See this page http://jsbin.com/arucu5/2/edit
In IE8 and Firefox the line through width increases with the font size.
However in Safari and Chrome it remains at 1px
You can always a dirty Ghetto method like this
http://www.overclock.net/web-coding/167926-ghetto-css-strike-through.html
This should work:
<style>
span.strike {
font-weight:bold; /*set line weight here*/
color:red;
text-decoration:line-through;
}
span.strike>span {
font-weight:normal;
color: black;
}
</style>
<span class="strike"><span>$20.00</span></span>
I've found another approach to set line weight for multiline text:
span {
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAADCAIAAADdv/LVAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAASSURBVHjaYvrPwMDEAMEAAQYACzEBBlU9CW8AAAAASUVORK5CYII=');
background-repeat: repeat-x;
background-position: center;
}
Here is an example:
http://output.jsbin.com/weqovenopi/1/
This approach assumes repeating an image (1px width and npx height). Also it works independent on the font-size.
Only one disadvantage - background renders under the text.
You can thicken the line with style.
For example:
text-decoration-thickness: 3px;
What is a good way to give the input field below the three characteristics listed?
Characteristics:
-Always 30 px from the left side of the browser window.
-Always 30 px below the words "Add a comment" if no comments have been added.
-Always 30 px below the preceding comment if one or more comment(s) has (have) been added.
Thanks in advance,
John
HTML / PHP Code:
<div class="addacomment"><label for="title">Add a comment:</label></div>
<div class="commentbox"><input class="commentsubfield" name="title" type="title" id="title" maxlength="1000"></div>
CSS (thusfar I have no declarations for the "commentbox" selector):
.commentsubfield { width: 390px; height: 90px; border: 1px solid #999999; padding: 5px; }
.addacomment
{
position:absolute;
width:250px;
left:30px;
top:180px;
text-align: left;
margin-bottom:3px;
padding:0px;
font-family:Arial, Helvetica, sans-serif;
font-size: 12px;
color:#000000;
}
First off, you don't need those <div>s. You can just add class="addacomment" to the label.
So you've got this:
<label class="addacomment" for="title">Add a comment:</label>
<?php print $your_comments_if_any; ?>
<input class="commentsubfield" name="title" type="title" id="title" maxlength="1000">
I'm not sure what DOCTYPE you're using, but you get the idea. Now for the CSS:
If you want to position something relative to the page, it's a good idea to keep the margins of the page in mind. Assuming the default, you'll want to set any margins or padding to 0:
html, body {
margin: 0;
padding: 0;
}
Now, the positioning you've done on .addacomment is basically keeping you from getting the result you want. I've stripped out the unnecessary stuff for clarity:
.addacomment {
display: block; /* override the default inline display */
margin-left: 30px; /* The 30px from the left you wanted */
}
Next, .commentsubfield only needs margins added to it:
.commentsubfield {
margin: 30px 0 30px 30px;
[your other styles]
}
That should give you the following result (this is an actual screenshot from Opera 10.10 OSX), although I find separating the label from its field quite weird:
form element positioning example http://img.skitch.com/20100329-pbyj117655wig4pfh8estxw9me.jpg
I would recommend keeping the input and corresponding label together.
Hope I understood your question correctly, and hope this helps.