Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make custom css button responsive?

I have created a CSS button but it is not responsive. I have tried adding EM or % but still not working. I want to change width and height according to the screen resolution.

Following is the CSS code I am actually using:

@media only screen and (min-width:321px) and (max-width:480px) { }

HTML

<div>
   <p>
      <button class="btn btn-1 btn-1a">Click Here To Enter The Future</button> 
   </p>
</div>

CSS

.btn {
  font-size:0.875em;
  display:block;
  left:-60px;
  margin-top:35px;
}

Right now the button is moving from left to right, but I want the button to appear at the exact same place.

like image 415
user3152357 Avatar asked Jan 03 '14 11:01

user3152357


People also ask

How do you make a responsive button in CSS?

use the flexbox property. The "cursor:pointer" changes the mouse cursor to pointer and the "font-size" and "height" are in rem unit just to make the button responsive. The "border:none" removes the annoying border and "border-radius:10px" makes the button edges circular (which is just nice).


1 Answers

You could add width:100%; to achieve your objective.

enter image description here

.btn {
      font-size:0.875em;
      display:block;
      left:-60px;
      margin-top:35px;
      width:100%;
    }
like image 120
Ali Gajani Avatar answered Sep 24 '22 22:09

Ali Gajani