Search
 
SCRIPT & CODE EXAMPLE
 

CSS

inline block align center

.parent {
  display: flex;
  justify-content: center;
  align-items: center;
}

.child {
  display: inline-block;
}
Comment

how to center a inline block element

  display: inline-block;
  position: relative;
  /* Move the element to the right by 50% of the container's width */
  left: 50%; 
  /* Calculates 50% of the element's width, and moves it by that */ 
  /* amount across the X-axis to the left */
  transform: translateX(-50%);
Comment

Center a Block element

//if i want to center a block element
then there a multipleways

<div class="parent">
  <div class="child" > </div>
</div>

1) first make the parent postion:realative;
2)child postion absolute so that you can use top,left,right,bottom props
3) set left:0 and right:0 and margin:auto and you child element will be center
4)margin:auto center a child element horizontally and leave equal space to 
its left and right so if you set left and right to  0 in child element
it means the child is to be set where the left is 0 since the position is
already absoulte than your element will then the left prop will be consider
from where the margin auto prop end thats the space left after horizantal center

second way
 position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);

1) the postion absolute force the element to consider the top and left props
directly from its parent that means the props will start
at the end of top 50% and left 50% and to balance it out we use
-50% to the y -axis and same to the x- axis this will center the
element
Comment

how to center three inline block elements

text-align: center; on the parent element
Comment

PREVIOUS NEXT
Code Example
Css :: souligner titre css 
Css :: css clip text 
Css :: how to change height font css 
Css :: bootstrap file upload 
Css :: change bootstrap input focus glow 
Css :: html css add Avenir light font 
Css :: css transition delay after hover 
Css :: timesheet template html css 
Css :: reset all input styles with 1 property css 
Css :: vertical line between two divs 
Css :: zoom animations in css 
Css :: set svg background color css 
Css :: image rotate css 
Css :: reset list html css 
Css :: how to let flex child take whole width 
Css :: how to set text in center in flex item 
Css :: for in sass 
Css :: css text 
Css :: close icon css 
Css :: add inner border css 
Css :: how to view downloading speed 
Css :: css blur bg 
Css :: input padding without changing width 
Css :: rem vs em 
Css :: how to move text down css 
Css :: how to make div possion top in css 
Css :: the background image properties in css 
Css :: backdrop css 
Css :: change default arrow icon for accordion in bootstrap 
Css :: autocomplete widget not working in modal popup 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =