Search
 
SCRIPT & CODE EXAMPLE
 

CSS

how to center an overlay button using flex box

display:flex;
align-items:center;
justify-content:center;
Comment

How to Center a Button using CSS Flexbox

//html
<h3>6 buttons</h3>
<div class="button-area">
  <a href="#">Button 1</a>
  <a href="#">Button 2</a>
  <a href="#">Button 3</a>
  <a href="#">Button 4</a>
  <a href="#">Button 5</a>
  <a href="#">Button 6</a>
</div>
<h3>5 buttons</h3>
<div class="button-area">
  <a href="#">Button 1</a>
  <a href="#">Button 2</a>
  <a href="#">Button 3</a>
  <a href="#">Button 4</a>
  <a href="#">Button 5</a>
</div>

<h3>3 buttons in a line</h3>
<div class="button-area-line">
  <a href="#">Button one with a lot more text than others</a>
  <a href="#">Button two</a>
  <a href="#">Button three</a>
</div>

<h3>4 buttons in a line</h3>
<div class="button-area-line">
  <a href="#">Button one with a lot more text than others</a>
  <a href="#">Button two info</a>
  <a href="#">Button three info</a>
  <a href="#">Button four info</a>
</div>


//css(scss)
@import "compass/css3";

h3 {
  text-align: center;
  max-width: 320px;
}
.button-area {
  margin: 10px auto;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  flex-wrap: wrap;
  max-width: 320px;
  a {
   background: #999;
    padding: 1em 2.4em;
    font-size: .9em;
    margin: 1em;
    color: white;
    text-decoration: none;
    flex-grow: 1;
    text-align: center;
  }
}


.button-area-line {
  margin: 10px auto;
  display: -webkit-box;   
  display: -moz-box;  
  display: -ms-flexbox; 
  display: -webkit-flex; 
  display: flex;
  -webkit-flex-direction: row;
  -moz-flex-direction: row;
  flex-direction: row;
  justify-content: space-between;
  flex-wrap: nowrap;
  max-width: 90%;
  a {
   background: #999;
    padding: 1em;
    font-size: .9em;
    margin: .3em;
    color: white;
    text-decoration: none;
    flex-grow: 1;
    text-align: center;
  }
}
Comment

PREVIOUS NEXT
Code Example
Css :: js click under 
Css :: background image css django 
Css :: chrome button black white border 
Css :: font size css 
Css :: mat-progress-bar style without app-theme 
Css :: check if swap is working 
Css :: how to write text on video in html 
Css :: responsive font size 
Css :: clearfix css 
Css :: centred div 
Css :: jquery .css multiple 
Css :: css caret-color property 
Css :: multiple css media queries 
Css :: css div bottom of parent 
Css :: css color gradient background full height 
Css :: gameloop programming language 
Css :: circle background image css 
Css :: scss install 
Css :: css rules only for mozilla 
Css :: css minifier api 
Css :: text outline css 
Css :: line break inside content css 
Css :: css grid full width row 
Css :: textarea resize only horizontal 
Css :: comfirm before delete 
Css :: css border properties 
Css :: ul list style type image 
Css :: border-radius cross browser 
Css :: styles only for IE 
Css :: css sticky navigatiojn 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =