PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, November 17, 2022

[FIXED] How make the middle sharp match the text line. The text is not in the sharp

 November 17, 2022     css, flexbox, vertical-alignment     No comments   

Issue

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>


Solution

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>



Answered By - Hunter Turner
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing