css - How to add image background to btn-default twitter-bootstrap button? -


i try design bootstrap v3.3.5 button using existing class btn-default, below sample of codes of had done.

<!-- latest compiled , minified css -->  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">    <!-- optional theme -->  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">    <!-- latest compiled , minified javascript -->  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>      <style type="text/css">    .sign-in-facebook    {      background-image: url('http://i.stack.imgur.com/e2s63.png');      background-position: -9px -7px;      background-repeat: no-repeat;      background-size: 39px 43px;      padding-left: 41px;      color: #000;    }    .sign-in-facebook:hover    {      background-image: url('http://i.stack.imgur.com/e2s63.png');      background-position: -9px -7px;      background-repeat: no-repeat;      background-size: 39px 43px;      padding-left: 41px;      color: #000;    }  </style>  <p>my current button got white background<br/>  <input type="button" value="sign in facebook" class="btn btn-default sign-in-facebook" style="margin-top:2px; margin-bottom:2px;" >  </p>  <p>i need current btn-default style below<br/>  <input type="button" class="btn btn-default" value="sign in facebook" />  </p>  <strong>note:</strong> facebook icon @ left side of button.

sample facebook icon:

sample fb-icon

how can modify class of .sign-in-facebook create own style button ?

instead of using input type button can use button , insert image inside button content.

<button class="btn btn-default">      <img src="http://i.stack.imgur.com/e2s63.png" width="20" /> sign in facebook </button> 

the problem doing css cannot set linear-gradient background must use solid color.

.sign-in-facebook {     background: url('http://i.stack.imgur.com/e2s63.png') #f2f2f2;     background-position: -9px -7px;     background-repeat: no-repeat;     background-size: 39px 43px;     padding-left: 41px;     color: #000;   }   .sign-in-facebook:hover {     background: url('http://i.stack.imgur.com/e2s63.png') #e0e0e0;     background-position: -9px -7px;     background-repeat: no-repeat;     background-size: 39px 43px;     padding-left: 41px;     color: #000;   } 

body {    padding: 30px;  }
<!-- latest compiled , minified css -->  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">    <!-- optional theme -->  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">    <!-- latest compiled , minified javascript -->  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>    <style type="text/css">    .sign-in-facebook {      background: url('http://i.stack.imgur.com/e2s63.png') #f2f2f2;      background-position: -9px -7px;      background-repeat: no-repeat;      background-size: 39px 43px;      padding-left: 41px;      color: #000;    }    .sign-in-facebook:hover {      background: url('http://i.stack.imgur.com/e2s63.png') #e0e0e0;      background-position: -9px -7px;      background-repeat: no-repeat;      background-size: 39px 43px;      padding-left: 41px;      color: #000;    }  </style>      <h4>only css</h4>    <input type="button" value="sign in facebook" class="btn btn-default sign-in-facebook" style="margin-top:2px; margin-bottom:2px;">    <h4>only html</h4>    <button class="btn btn-default">    <img src="http://i.stack.imgur.com/e2s63.png" width="20" /> sign in facebook  </button>


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -