skip to Main Content

I’m trying to create a responsive button from a photoshop mockup in HTML and CSS. Here is the button mockup:

enter image description here

I’m struggling with how to get the arrow in the white space and to stay there through different screen sizes.

I created the color separation through a gradient, like this:

HTML

<button> All Team Members </button>

CSS

button {
   /* Permalink http://colorzilla.com/gradient-editor/#990033+0,990033+50,990033+86,ffffff+86,ffffff+100 */
   width: 70%;
   font-size: .6em;
   font-size: 3.4vw;
   padding: 2%;
   color: #ffffff;
   outline-color: #990033;
   background: rgb(153,0,51); /* Old browsers */
   background: -moz-linear-gradient(left, rgba(153,0,51,1) 0%, rgba(153,0,51,1) 50%, rgba(153,0,51,1) 86%, rgba(255,255,255,1) 86%, rgba(255,255,255,1) 100%); /* FF3.6+ */
   background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(153,0,51,1)), color-stop(50%,rgba(153,0,51,1)), color-stop(86%,rgba(153,0,51,1)), color-stop(86%,rgba(255,255,255,1)), color-stop(100%,rgba(255,255,255,1))); /* Chrome,Safari4+ */
   background: -webkit-linear-gradient(left, rgba(153,0,51,1) 0%,rgba(153,0,51,1) 50%,rgba(153,0,51,1) 86%,rgba(255,255,255,1) 86%,rgba(255,255,255,1) 100%); /* Chrome10+,Safari5.1+ */
   background: -o-linear-gradient(left, rgba(153,0,51,1) 0%,rgba(153,0,51,1) 50%,rgba(153,0,51,1) 86%,rgba(255,255,255,1) 86%,rgba(255,255,255,1) 100%); /* Opera 11.10+ */
   background: -ms-linear-gradient(left, rgba(153,0,51,1) 0%,rgba(153,0,51,1) 50%,rgba(153,0,51,1) 86%,rgba(255,255,255,1) 86%,rgba(255,255,255,1) 100%); /* IE10+ */
   background: linear-gradient(to right, rgba(153,0,51,1) 0%,rgba(153,0,51,1) 50%,rgba(153,0,51,1) 86%,rgba(255,255,255,1) 86%,rgba(255,255,255,1) 100%); /* W3C */
   filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#990033', endColorstr='#ffffff',GradientType=1 ); /* IE6-9 */
}

And it currently looks like this:

enter image description here

What is the best way to move forward? I wondered if I should just use screenshots of the button from the mockup, or if I should make it in CSS. How can I make the button look like this and be responsive?

2

Answers


  1. try this:

    .btn {padding:10px 40px 10px 20px;
        width:70%;
        border-radius:3px;
        border:2px solid inherit;
    border-color: #eeeeee;
        background-color:rgb(153,0,51);
        background-position:center right;
        background-repeat:no-repeat;
        text-align:center;
     filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#990033', endColorstr='#ffffff',GradientType=1 ); /* IE6-9 */
        font-size: .6em
    
        }
         .white_txt {color:#ffffff!important;}
         .purple_btn {border:2px solid #eeeeee;border-radius:3px;}
    

    <div class="purple_btn btn"> 
        <div class="white_txt">All Team Members</div>
    </div>
    
    Login or Signup to reply.
  2. Use pseudo elements :before and :after, to make the background and the arrow. Use Font Awesome etc if you need a different shape of arrow.

    button {
        font-size: 3vw;
        padding: 2vw;
        color: #ffffff;
        background: #903;
        border: 0;
        position: relative;
        padding-right: 8vw;
    }
    button:before {
        content: '';
        width: 6vw;
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        background: white;
        border: 1px solid #903;
    }
    button:after {
        content: '❯';
        position: absolute;
        right: 2vw;
        color: #903;
    }
    <button>All Team Members</button>

    jsfiddle

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search