CSS button class breaking links - html

I'm using CSS3 buttons for a website I'm working on. However it would appear that the CSS controlling these buttons is breaking the links it styles. If anyone could point out where I am going wrong that would be greatly appreciated.
CSS controlling buttons:
.button {
display: inline-block;
zoom: 1; /* zoom and *display = ie7 hack for display:inline-block */
*display: inline;
vertical-align: baseline;
margin: 0 2px;
outline: none;
cursor: pointer;
text-align: center;
text-decoration: none;
font: 14px/100% Arial, Helvetica, sans-serif;
padding:5px 15px;
text-shadow: 0 1px 1px rgba(0,0,0,.3);
-webkit-border-radius: .5em;
-moz-border-radius: .5em;
border-radius: .5em;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.2);
-moz-box-shadow: 0 1px 2px rgba(0,0,0,.2);
box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.button:hover {
text-decoration: none;
}
.button:active {
position: relative;
top: 1px;
}
.blue {
color: #d9eef7;
background: #0095cd;
background: -webkit-gradient(linear, left top, left bottom, from(#009DD1), to(#009DD1));
background: -moz-linear-gradient(top, #009DD1, #009DD1);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00adee', endColorstr='#0078a5');
}
.blue:hover {
background: #007ead;
background: -webkit-gradient(linear, left top, left bottom, from(#0095cc), to(#00678e));
background: -moz-linear-gradient(top, #0095cc, #00678e);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0095cc', endColorstr='#00678e');
}
.blue:active {
color: #FFFFFF;
background: -webkit-gradient(linear, left top, left bottom, from(#0078a5), to(#00adee));
background: -moz-linear-gradient(top, #0078a5, #00adee);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0078a5', endColorstr='#00adee');
}
And the offending links:
<div class="nav">
<a href='http://www.twantrum.com/mild.html' target="_top" class='button blue'>Mild</a>
<a href='http://www.twantrum.com/restrained.html' target="_top" class='button blue'>Restrained</a>
<a href='http://www.twantrum.com/angry.html' target="_top" class='button blue'>Angry</a>
<a href='http://www.twantrum.com/mel-gibson.html' target="_top" class='button blue'>Mel Gibson</a>
</div>

There is no error in the markup you posted.
Looking at your page itself though, i noticed this section, which produces the error:
<script type="text/javascript">
$(document).ready(function(){
$('.button').click(function(){ return false; });
});
</script>
Why this does not work is answered here: What's the effect of adding 'return false' to a click event listener?
Hope it helps.

Related

CSS -> Hover effect dosen't work

My CSS Code don't detect, if my cursor over the div: But if i active "hover" with the browser developer tool, it works.
Explain: The Div shows, if I go over a button, but the div hide out, if i go out of the button...
My code:
.profilanzeige2 {
width: 20%;
float: right;
position: absolute;
text-align: center;
padding: 10px;
top: -250px;
right: 0px;
z-index: -1;
border-radius: 0px 0px 10px 10px;
color: white;
/* border: 1px solid #797979; */
background-image: none;
background: #16b751;
background: -moz-linear-gradient(top, #16b751 0%, #19ad46 100%);
background: -webkit-linear-gradient(top, #16b751 0%,#19ad4619ad46 100%);
background: linear-gradient(to bottom, #16b751 0%,#19ad46 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#16b751', endColorstr='#19ad46',GradientType=0 );
transition: top 1s ease-in-out;
border: 1px solid #e7e7e7;
}
#profilanzeige:hover ~ #profilanzeige2, .profilanzeige2:hover {
top: 54px !important;
}
#profilanzeige:hover + #profilanzeige2, .profilanzeige2:hover {
top: 54px !important;
}
.profil:hover ~ #profilanzeige2, #profilanzeige2:hover {
top: 54px !important;
}
.profil:hover + #profilanzeige2, #profilanzeige2:hover {
top: 54px !important;
}
<div class="profilanzeige2" id="profilanzeige2">
<img src="https://ftimg.de/images/2017/03/02/5e2c4f6af5024d26bb95d074a3ed9a86.png">
<p class="profil-name"><?php echo $user['icname']; ?></p>
<a href="profil.php"><button type="button" class="btn btn-default" class="Profilanzeigen">
Profil anzeigen
</button></a>
<a href="logout.php"><button type="button" class="btn btn-default" class="Abmelden" href="logout.php">
Abmelden
</button></a>
</div>
You have
<div class="profilanzeige2" id="profilanzeige2">
with class profilanzeige2 but the :hover is on #profilanzeige
Another thing which could be improved, for the sake of readability, is to have different names of the class and the id in the div.
Fixxed, i had z-index on -1. I change it to over 0 and all work fine.

Text color not changing on hover

Quick CSS/HTML issue here, please excuse my lack of experience in the field.
I have a download button that I would like to change from having white text to having grey text on hover. Currently the text is white, however despite my defining of a :hover attribute to change the color, it remains white. Here's my code:
HTML:
<a id="postLink" class="button2" href="#">Post</a>
CSS:
.button2 {
display: inline-block;
width:163px;
color: #FFFFFF;
text-align: center;
vertical-align: middle;
padding: 12px 24px;
border: 1px solid #EFEFEF;
border-radius: 8px;
background: #589edb;
font: normal normal normal 20px raleway;
text-decoration: none;
z-index:150;
}
.button2 :hover{
color:#555555;
}
.button2:focus {
border: 1px solid #EFEFEF;
background: #589edb;
background: -webkit-gradient(linear, left top, left bottom, from(#6abeff), to(#6abeff));
background: -moz-linear-gradient(top, #589edb, #589edb);
background: linear-gradient(to bottom, #589edb, #589edb);
text-decoration: none;
}
.button2:active {
background: #589edb;
color:#FFFFFF;
}
#postLink{
color:#FFFFFF;
&:hover{
color:#55555;
}
}
Thanks!
Your .button2 :hover should be .button2:hover the whitespace screws it up ;)
I would remove the
#postLink{
color:#FFFFFF;
&:hover{
color:#55555;
}
}
as it adds nothing and might screw up your code. Are you using LessCSS or SASS? Otherwise, &:hover will not work. Then the #postLink will prioritise over the class and will keep it white.

Firefox button gets bigger

I have a button and an anchor tag booth using the same class, but the button gets bigger for some reason. I found a question here already solved but it still is a little bit bigger than the other.
HTML:
<div class="item-actions">
<ul>
<li><i class="fa fa-trash"></i> Gravar</li>
<li><button type="submit" class="button"><i class="fa fa-trash"></i> Lixo</button></li>
</ul>
</div>
CSS:
.item-actions{
float: right;
}
.item-actions ul li{
display: inline-block;
}
.button {
background: #3a9665;
background-image: -webkit-linear-gradient(top, #3a9665, #2d7a51);
background-image: -moz-linear-gradient(top, #3a9665, #2d7a51);
background-image: -ms-linear-gradient(top, #3a9665, #2d7a51);
background-image: -o-linear-gradient(top, #3a9665, #2d7a51);
background-image: linear-gradient(to bottom, #3a9665, #2d7a51);
-webkit-border-radius: 2;
-moz-border-radius: 2;
border-radius: 2px;
font-family: Arial;
color: #ffffff;
font-size: 12px;
padding: 4px 12px 4px 12px;
border: solid #2d7a51 1px;
text-decoration: none;
}
.button:hover {
background: #2d7a51;
text-decoration: none;
}
Here I found a Solution so I added this bit of CSS:
button::-moz-focus-inner {
padding: 0;
border: 0
}
But the result still isn't what I want, you will notice some difference in the following screenshot:
EDIT:
I've removed i tags and the problem still exists, so thats not the problem.
I can recreate the issue on Mac OS X 10.9.5 with FireFox version 32.0.2. Adding line-height: 1em; to .button seems to work when I test it in FireFox:
.button {
background: #3a9665;
background-image: -webkit-linear-gradient(top, #3a9665, #2d7a51);
background-image: -moz-linear-gradient(top, #3a9665, #2d7a51);
background-image: -ms-linear-gradient(top, #3a9665, #2d7a51);
background-image: -o-linear-gradient(top, #3a9665, #2d7a51);
background-image: linear-gradient(to bottom, #3a9665, #2d7a51);
-webkit-border-radius: 2;
-moz-border-radius: 2;
border-radius: 2px;
font-family: Arial;
color: #ffffff;
font-size: 12px;
line-height: 1em;
padding: 4px 12px 4px 12px;
border: solid #2d7a51 1px;
text-decoration: none;
}
I believe the issue’s cause comes from <button type="submit" class="button"> tag having explicit styling while your <a href="#" class="button"> doesn’t:
<div class="item-actions">
<ul>
<li><i class="fa fa-trash"></i> Gravar</li>
<li><button type="submit" class="button"><i class="fa fa-trash"></i> Lixo</button></li>
</ul>
</div>
Also could be caused by the use of explicit pixel sizing in .button with font-size: 12px;. I would recommend using another scheme for sizing such as em’s or even percentages.
try to set the line-height of icons to 1:
.fa {
line-height: 1;
}

adjusting background color gradient of a submit button with css

Hi i want to style an input submit button which has a background as given in the attached image.The back ground image was provided, but im not sure how to implement it in the submit button so instead of using that image i tried using the css 3 color gradient properties to style the button,however, i cant get the desired color output.Any help is welcome.
CSS code so far.
.button {
-moz-border-radius: 18px;
-moz-box-shadow: #fffff 0px 0px 11px;
-webkit-border-radius: 18px;
-webkit-box-shadow: #6E7849 0 0 10px;
background-color: #fefefefe;
background-image: -moz-linear-gradient(24deg, #d8d8d8, #fefefefe);
background-image: -ms-linear-gradient(24deg, #d8d8d8, #fefefefe);
background-image: -o-linear-gradient(24deg, #d8d8d8, #fefefefe);
background-image: -webkit-linear-gradient(24deg, #d8d8d8, #fefefefe);
background-image: linear-gradient(24deg, #d8d8d8, #fefefefe);
border-radius: 18px;
border: 1px solid #888888;
box-shadow: #fffff 0px 0px 11px;
color: #000000;
display: inline-block;
font-size: 3em;
margin: auto;
padding: 4px;
text-decoration: none;
}
Use the image. Matching the gradient fully to the image is an unnecessary pain:
.button {
display:block;
width:50px; //use actual image width
height:50px; // use actual image height
background:url(../img/button.png); //image file path
}
.button:hover {
background:url(../img/button_hover.png);
}
To use an image as the input is very simple:
<input type="image"src="/images/submit.gif" />
Finally i found the way to make this button using sliding door technique.However still in jeopardy to style it in disabled state.
This link helped me alot http://www.springload.co.nz/love-the-web/dynamic-submit-buttons
css
div.submit_button {
background: transparent url('common/images/bg-submit2.png') no-repeat 0 0;
display: block;
float: left;
height: 27px; /* total height of the button */
padding-left: 15px; /* end width */
}
span.submit_button_end {
background: #fff url('common/images/bg-submit2.png') no-repeat 100% 0; /* used a sprite image */
display: block;
float: left;
font-weight: normal;
height: 27px; /* total height of the button */
}
input.submit_input {
font-size: 13px;
font-weight:bold;
background: none;
border: none;
padding: 0 0 2px 15px; /* end width */
color: #1b1d60;
cursor: pointer;
position: relative;
height: 25px;
line-height: 25px;
left: -15px;
margin-right: -15px;
padding-right: 15px;
}
input.submit_input:hover {color: #fff;}
div.submit_button:hover {background-position: 0 100%;}
div.submit_button:hover span.submit_button_end {background-position: 100% 100%;}
HTML
<div class='submit_button'>
<span class='submit_button_end'>
<input class='submit_input' type='submit' value='Submit button' tabindex='#' />
</span>
</div>

HTML Button with CSS

I have this CSS for a button-
a.button {
border-top: 1px solid #7f93bc;
background: #7f93bc;
background: -webkit-gradient(linear, left top, left bottom, from(#7f93bc), to(#7f93bc));
background: -moz-linear-gradient(top, #7f93bc, #7f93bc);
padding: 10.5px 21px;
-webkit-border-radius: 0px;
-moz-border-radius: 0px;
border-radius: 0px;
-webkit-box-shadow: rgba(0,0,0,1) 0 1px 0;
-moz-box-shadow: rgba(0,0,0,1) 0 1px 0;
box-shadow: rgba(0,0,0,1) 0 1px 0;
text-shadow: rgba(0,0,0,.4) 0 1px 0;
color: white;
font-size: 18px;
font-family: 'Lucida Grande', Helvetica, Arial, Sans-Serif;
text-decoration: none;
vertical-align: middle;
}
a.button:hover {
border-top-color: #0e1f5b;
background: #0e1f5b;
color: #ffffff;
}
a.button:active {
border-top-color: #0e1f5b;
background: #0e1f5b;
}
The below turns out a link. I want to make it turn out a button in the above style. What can I replace the below with?
$theOffers .= "<br><li class=\"gateway-offer\">$offer[name]</li><br>";
Just add the class to the tag:
...ffer\"><a class=\"button\" href=\"http://fakeurlf...
Looks like you just need to add class="button" to your anchor tag, like so:
$theOffers .= "<br><li class=\"gateway-offer\"><a class=\"button\" href=\"http://fakeurlforanon/aff_c?offer_id=".$offer['id']."&aff_id=$affiliateId\" target=\"_blank\">$offer[name]</a></li><br>";
That should make it pick up all the button styling you already have.
You forgot to actually specify that the <a> should be of class button.
$theOffers .= '
<br />
<li class="gateway-offer">
<a class="button" href="http://fakeurlforanon/aff_c?offer_id=' . $offer["id"] . '&aff_id=' . $affiliateId. '" target="_blank">' . $offer["name"] . '</a>
</li><br />';