1

EDIT : there is others post which answers to my post but I let my post online because some people don't know that is about "vertical alignment in flexbox" trick. My topic allow to make a link with it.

I try to make the middle of my sharp match the line of text.

I have try flexbox and even grid but don't figure out what is wrong.

What I want to do :

enter image description here

Here my Jsfiddle, if someone got any idea to make it :

http://jsfiddle.net/rkEMR/10617/

div{ 
display: flex;
  align-items: center;

} #record {
   grid-area: text;
   border: solid;
   border-color: #656666;
   border-width: 1px;
   margin-left: 3.8em;
   margin-top: 0.3em;
   width: 10rem;
   height: 3rem;
   background-color: white;
   font-family: 'Tajawal', sans-serif;
   font-size: 1.5em;
   text-align: center; 
 }

 #circle {
   display: inline-block;
   grid-area: symbol;
   margin: 0;
   padding: 0;
   background: red;
   width: 25px;
   height: 25px;
   text-align: center;
   -webkit-border-radius: 50px;
   -moz-border-radius: 50px;
   border-radius: 50px;
  /* padding-top: 5px;
   line-height:  5em;*/
 }
<div> <button id="record"> Record <div id="circle"> </div></button>
</div>
Webwoman
  • 10,196
  • 12
  • 43
  • 87

1 Answers1

0

Your flex properties are in the wrong place. You need to apply them to the direct parent of the elements you want to be centered, which would be #record.

If you apply:

#record {
  display: flex;
  justify-content: center;
  align-items: center;
}

The contents of your button will be centered.

#record {
   grid-area: text;
   border: solid;
   border-color: #656666;
   border-width: 1px;
   margin-left: 3.8em;
   margin-top: 0.3em;
   width: 10rem;
   height: 3rem;
   background-color: white;
   font-family: 'Tajawal', sans-serif;
   font-size: 1.5em;
   text-align: center;
   display: flex;
   justify-content: center;
   align-items: center;
 }

 #circle {
   display: inline-block;
   grid-area: symbol;
   margin: 0;
   margin-left: 10px;
   padding: 0;
   background: red;
   width: 25px;
   height: 25px;
   text-align: center;
   -webkit-border-radius: 50px;
   -moz-border-radius: 50px;
   border-radius: 50px;
  /* padding-top: 5px;
   line-height:  5em;*/
 }
<div> <button id="record"> Record <div id="circle"> </div></button>
</div>
Hunter Turner
  • 6,804
  • 11
  • 41
  • 56