Link button color HTML/CSS [closed] - html

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I have quite a problem, I created a button that leads to an iTunes page.
When I did the CSS I had no problem until I noticed that I didnt link the button to the page. So when I did, I couldn't disable the underline of my text inside my button.
I worked my way through and now I'm stuck with a text that is not underlined and changes color when hovered as I wanted. Only thing is that the border doesn't change color at the same time as the text.
Example: I can hover (and thus change the color) my border without touching my text, and obviously this is not what I want.
Snippet :
.navigation{
background-color:#C5C5C5;
}
.btniTunes {
margin-left: 150px;
margin-top: 150px;
font-family: 'Roboto', sans-serif;
background-color: transparent;
border: 1px solid #ffffff;
display: inline-block;
cursor: pointer;
color: white;
font-size: 18px;
padding: 10px 18px;
text-decoration: none;
}
.btniTunes:hover {
background-color: black;
color: #E80C7A;
border: 1px solid #E80C7A;
text-decoration: none;
}
.btniTunes a {
text-decoration: none;
color: white;
}
<nav class="navigation">
<ul class="bouttons">
<div class="btnSite">
TO THE SITE
</div>
<div class="btniTunes">
TO THE ITUNES
</div>
</ul>
</nav>
So basically, I want to have a button that links to a page, with black background, white text and border, that has the text and border color that changes to #E80C7A when hovered and without underline on the text.

Just close the brackets in css:
.btniTunes {
margin-left:150px;
margin-top: 150px;
font-family: 'Roboto', sans-serif;
background-color:transparent;
border:1px solid #ffffff;
display:inline-block;
cursor:pointer;
color:white;
font-size:18px;
padding:10px 18px;
text-decoration:none;
}
.btniTunes:hover {
background-color:black;
color:#E80C7A;
border:1px solid #E80C7A;
text-decoration:none;
}
.btniTunes a {
text-decoration:none;
color: white;
}
and also if you want the <a> to cover the button, set its "display" to the block:
.btniTunes a {
text-decoration:none;
color: white;
display:block;
width:100%;
height:100%;
}

Here you are :)
Remove the padding from .btniTunes and add it to .btniTunes a and add display: block; to it.
.btniTunes {
margin-left: 150px;
margin-top: 150px;
font-family: 'Roboto', sans-serif;
background-color: red;
border: 1px solid #ffffff;
display: inline-block;
cursor: pointer;
color: white;
font-size: 18px;
text-decoration: none;
}
.btniTunes:hover {
background-color: black;
color: #E80C7A;
border: 1px solid #E80C7A;
text-decoration: none;
}
.btniTunes a {
display: block;
padding: 10px 18px;
text-decoration: none;
color: white;
}
.btniTunes:hover a {
color: #E80C7A;
}
<nav class="navigation">
<ul class="bouttons">
<div class="btnSite">
TO THE SITE
</div>
<div class="btniTunes">
TO THE ITUNES
</div>
</ul>
</nav>

Related

How do keep position when borders appear? [duplicate]

This question already has answers here:
CSS hover border makes elements adjust slightly
(14 answers)
Closed 2 years ago.
I am trying to keep on the position when it creates borders of the list elemants on the menu.
When i do border box is looks "it is not working" (ı am sure it is , but i cant see it )
Here is the my basic Html Code
<div class="menu-bar">
<ul>
<li>Anasayfa</li>
<li>Hakkımızda</li>
<li>Kadromuz</li>
<li>Çalışma Alanlarımız</li>
<li>Vekalet bilgileri</li>
<li>İletişim</li>
</ul>
</div>
Here is my Css Code
.menu-bar{
width: 1000px;
height: 50px;
background-color:#212331;
box-sizing: border-box;
}
.menu-bar ul {
margin-top: 0px;
list-style-type: none;
}
.menu-bar li {
display: inline-block;
margin-left: 30px;
}
.menu-bar a {
font-family:'Open Sans', sans-serif;
font-weight: bold;
color:#ffffff;
text-decoration: none;
line-height: 50px;
padding: 15px 10px;
}
.menu-bar a:hover{
border:2px solid red;
color: #cf9452;
transition: 0.5s;
}
Here is the what is actually going on the page .
Instead of the border use this -
.menu-bar a:hover {
box-shadow: inset 0 0 0 2px red;
}
This should fix it for you
.menu-bar a {
border:2px solid transparent;
}

My button isnt working

HTML code:
<div id="but_2" class="button">
Portfolio
</div>
<div id="but_1" class="button">Home</div>
CSS code:
.button {
background-color: #ff0000;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
#but_1 {
position: absolute;
right: 50px;
top:20px;
}
My css button isn't working, it brings me to where I need to be, but it is blue and is underlined(the text in the button) I have text-decor none, but it still isnt going away.
Target the a element to remove the underline and change the color. You can target it with .button a {}
.button {
background-color: #ff0000;
border: none;
padding: 15px 32px;
text-align: center;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
#but_1 {
position: absolute;
right: 50px;
top: 20px;
}
.button a {
text-decoration: none;
color: white;
}
<div id="but_2" class="button">Portfolio
</div>
<div id="but_1" class="button">Home</div>
You need to be more specific and target the a href attribute.
For example:
.button a {
text-decoration: none;
color: #000;
}
https://jsfiddle.net/xojev64e/
a {text-decoration: none; color:#FF0000;} shows unvisited link
a:visited {color:#FF0000;} shows visited link
a:hover {color:#FF0000;} shows mouse over link
a:active {color:#FF0000;} show selected link
use all property to define you color
I think you have not clear your browsing history of your browser. First clear you history, session, or cookie and then perform following steps.
Add following to your css file
.button a {
text-decoration: none;
color: white;
}
And add this for more attraction on mouseover
.button a:hover {
text-decoration: none;
color: black;
}
Hope this will help you.. :)

Why I cannot center my nav bar?

h1{
text-align:center;
font-family: 'Nosifer', cursive;
font-size:35px;
}
nav {
border-top: 5px solid black;
padding:5px 5px;
text-align:center;
}
nav a:link,a:visited {
border-radius: 0 0 15px 15px;
padding:0px 15px;
}
nav a {
float: left;
font-weight: bold;
color: #000;
margin: 0 5px;
background-color: #131313;
font-family: 'Nosifer', cursive;
text-decoration: none;
font-size: 20px;
color:red;
}
nav a:hover {
background-color: #D10000;
color: black;
padding-top: 12px;
padding-bottom: 10px;
}
.active{
background-color: #D10000;
color: black;
padding-top: 12px;
padding-bottom: 10px;
}
body{
background-color: #ffe6e6;
}
<nav>
HOME
COMPUTER PARTS
BUILD A COMPUTER
MEDIA
GO TO MAIN
</nav>
Can anyone please help me. I tried to use align="center", text-align:center;
and I tried many other things but for some reason, it's not centering my nav bar in the center of my web page. Also when I tried to display an image at the bottom of the nav bar and center it, it does not center.
Without seeing your markup, it's hard to say. But probably because of float: left on nav a. Remove that from nav a, and add display: inline-block;.
You're not even positioning anything...
Use the properties top: value, left: value, right: value, and bottom: value to position your navigation bar. You can use these properties in combination with transform: translate(X, Y).
text-align will only align text within an element, if there is indeed text. If there isn't any text, it won't do anything.
You need remove 'float: left' from 'nav a' selector and re-write code following way:
nav a {
display: inline-block;
font-weight: bold;
color: #000;
margin: 0 5px;
background-color: #131313;
font-family: 'Nosifer', cursive;
text-decoration: none;
font-size: 20px;
color:red;
}

Styles not being overridden with image

I have a web page with a set of links I styled that lead you to other pages. One of these pages is a gallery of photos.
When I try to link the thumb-nail to the larger image, I get this black border about 2-3 pixels high and slightly wider than the thumbnail. I have tried everything to override and get rid of this, but nothing I do seems to work.
a:link,a:visited {
display: inline;
font-weight: bold;
color: #FFFFFF;
padding-top: 10px;
padding-bottom: 10px;
padding-right: 30px;
padding-left: 30px;
margin: 10px;
text-align: center;
text-decoration:none;
border: 2px solid black;
}
a:hover {
background-color: #3bb2cE;
border: 2px solid black;
transition-property: background-color;
transition-duration: 1s;
}
a:active {
background-color: #3bb2cE;
border: 2px solid black;
}
.link2 a:link, .link2 a:hover; .link2 a:active {
margin: 10px;
border: none;
}
link2 is what I am trying to override the CSS with. It's not working even in the HTML:
<a class="link2" href="images/stairs1.jpg"><img src="images/stairs1_thumb.jpg" /></a>
<a class="link2" href="images/staris2.jpg"><img src="images/stairs2_thumb.jpg" /></a>
Here is an image of what is happening:
If you can't remove the border, and you merely need to overwrite the border, use:
a.link2 {
margin: 10px;
border: none;
}
jsFiddle example - it works.
Your other styling, (.link2 a:link, .link2 a:hover; .link2 a:active), wasn't being applied.
The selector, .link2 a:link is selecting an a elements, who is a link, and child of an element with class .link2.. this obviously doesn't work, as .link2 is the a element you are trying to remove the border from.
Simply put, just use a.link2, which selects an a elements with class .link2.
As the demo demonstrates, this will effectively overwrite the initial styling, removing the border.
Remove this from your css
border: 2px solid black;
no need to remove any css
http://jsfiddle.net/cancerian73/bX4WH/1/
a:link, a:visited {
display: inline;
font-weight: bold;
color: #FFFFFF;
padding-top: 10px;
padding-bottom: 10px;
padding-right: 30px;
padding-left: 30px;
margin: 10px;
text-align: center;
text-decoration:none;
border: 2px solid black; /*for no border remove this*/
display:inline-block; /*add this*/
}

Custom select not working on IE9

I have this select that is behaving strange on IE9.
First of all links that should open wiki page not working only on IE9 browser and second problem is on hover, why when cursor pass over help and log off the icon is overridden by hover background color?
<ul id="main">
<li class="username" tabindex="1" > <a>USER</a>
<ul class="curent_buser">
<li class="help">Help</li>
<li class="logoff">LogOff</li>
</ul>
</li>
</ul>
CSS:
ul#main {
color: gray;
width: 120px;
border-left: 1px solid #f2f2f2;
border-right: 1px solid #f2f2f2;
border-top: 1px solid #f2f2f2;
list-style: none;
font-size: 12px;
letter-spacing: -1px;
font-weight: bold;
text-decoration: none;
height:30px;
background:green;
}
ul#main:hover {
opacity: 0.7;
text-decoration: none;
}
#main > li{
background: url('http://cdn1.iconfinder.com/data/icons/crystalproject/24x24/actions/1downarrow1.png') 100% 0 no-repeat;
outline:0;
padding:10px;
}
ul#main li ul {
display: none;
width: 116px;
background: transparent;
border-top: 1px solid #eaeaea;
padding: 2px;
list-style: none;
margin: 7px 0 0 -3px;
}
ul.curent_buser li a {
color: gray;;
cursor: pointer;
}
ul.curent_buser{
background:lime !important;
}
ul#main li ul li a {
display: block;
padding: 5px 0;
position: relative;
z-index: 5;
}
#main li:focus ul, #main li.username:active ul {
display: block;
}
.help{
background: url("http://cdn1.iconfinder.com/data/icons/musthave/16/Help.png") no-repeat 100% center ;
height: 25px;
margin-bottom: 2px;
border-bottom: 1px solid white;
}
.help:hover{
background: #f4f4f4;
}
.logoff{
background: url("http://cdn1.iconfinder.com/data/icons/cc_mono_icon_set/blacks/16x16/on-off.png") no-repeat 100% center ;
height: 25px;
}
.logoff:hover{
background: #f4f4f4 ;
height: 25px;
}
.help a,.logoff a{
color:gray;
font-family: Museo700Regular,sans-serif;
letter-spacing: 0;
font-size: small;
}
​
Fiddle: http://jsfiddle.net/RwtHn/1455/
I can at least help you with the Icon issue. The issue is that you are overidding the background with a color. You can have a color or a background image. Not both. You will need to either have a different image in the background that is essentially the same but with different colors, do without the image when you hover or do without the color when you hover.
I'm sorry I can't be more helpful with the IE problem. I sincerely hate IE for things like this.
EDIT: This is something that you can do as mentioned in the comment below
.logoff:hover{
background: #f4f4f4 url("http://cdn1.iconfinder.com/data/icons/cc_mono_icon_set/blacks/16x16/on-off.png");
height: 25px;
}
Thanks ANeves for this information. I learnt something here too.
OK, for the overridden icon issue credits goes for "ANeves",
but you may use below CSS for preventing extra code lines:
#main > li > ul > li:hover
{
background-color: #f4f4f4;
}
for the IE9 clicking issue, just add below CSS:
#main ul:hover
{
display: block;
}
and that's it
thanks to http://www.cssplay.co.uk/menus/cssplay-click-click.html
On hover you are overriding the background property. Since this property has both the colour and the image, you are overriding the image as well.
Set only the colour, then:
.help:hover{
background-color: #f4f4f4;
}
.logoff:hover{
background-color: #f4f4f4 ;
}
http://jsfiddle.net/RwtHn/1456/