dr0zd
dr0zd

Reputation: 1378

Link and button with the same style

I use the same style for link and button. But they look different. How can I get the same look?

<button class="button blue">Hello</button>
<br /><br />
<a class="button blue" href"#">Hello</a>



body {
    background-color: #ccc;
    font-family: Arial;
    font-size: 12px;
    color: #747476;
    margin: 0 0 15px 0;
    height: 100%;
    width: 100%;
}

button, a.button {
    width: auto;
    min-width: 110px;
    height: 30px;
    line-height: 30px;
    padding: 10px;
    border: 0 none;
    font-weight: bold;
    text-align: center;
    cursor: pointer;
    text-decoration: none;
    font-family: Tahoma;
}

button.button, a.button {
    color: #fff !important;
}

button.button.blue, a.button.blue {
    background-color: #2bb0df;
}

button.button.orange, a.button.orange {
    background-color: #e95d0f;
}

JsFiddle

Upvotes: 0

Views: 57

Answers (1)

connexo
connexo

Reputation: 56813

Just add the following two lines to your css code for button, a.button:

box-sizing: content-box; display: inline-block;

and you're done.

body {
  background-color: #ccc;
  font-family: Arial;
  font-size: 12px;
  color: #747476;
  margin: 0 0 15px 0;
  height: 100%;
  width: 100%;
}
button,
a.button {
  width: auto;
  min-width: 110px;
  height: 30px;
  line-height: 30px;
  padding: 10px;
  border: 0 none;
  font-weight: bold;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  font-family: Tahoma;
  display: inline-block;
  box-sizing: content-box;
}
button.button,
a.button {
  color: #fff !important;
}
button.button.blue,
a.button.blue {
  background-color: #2bb0df;
}
button.button.orange,
a.button.orange {
  background-color: #e95d0f;
}
<button class="button blue">Hello</button>
<br />
<br />
<a class="button blue" href "#">Hello</a>

Upvotes: 1

Related Questions