Horizontally Center content

There are various methods to center align text as well any HTML content. Center aligning the text is pretty simple and can be done using just text-align:center property as following.

But what if when you have to center align any HTML element with any content inside it. In that case you can use any of the following method: 1. Horizontally Center content using margin : 0 auto You can use margin : 0 auto to any parent element and than your content inside it will be horizontally center align relative to it. Consider the below HTML structure for horizontally center align …

Continue Reading

Absolute Horizontal And Vertical Centering In CSS

There are many situation in CSS coding, when you wants to keep your content/text right at center both horizontally as well as vertically relative to it’s parent container element. In order to do Absolute Horizontal And Vertical Centering In CSS, we used to had various options as follow: Using absolute position & transition together. Let us first quickly dive right into above methods one by one and than we will discuss the new and better method to do it. Using absolute position & transition together: Let’s consider the following HTML structure.

I have two set of HTML structure in it. First having only …

Continue Reading

Vertical Center content

We all know very well that placing the Vertical Center content was always a pain. Previously, we used to achieve this by following 2 techniques but now we can also achieve the same using display: flex.   First Method (Using Display : inline-block) Second method (Using Display : table) Third Method (Using Display : Flex)   Let’s consider the simple HTML structure:

First Method (Using Display : inline-block) In first method, you can achieve the same using Display : inline-block as following :

Demo Fiddle : See the Pen vertical center content using Inline-block by Techhysahil (@techhysahil) on CodePen. Second …

Continue Reading

Placeholder selector in SCSS

Sass full form is  “Syntatically Awesome Style Sheets” and it is preprocessing CSS library which allows us to use various cool feature like variable, function, nesting, mixins, placeholder etc. I love all of these features because it make my life easy and create style dynamically. Today i will discuss one feature of Sass which is known as “Placeholder selector in Sass”.   Sass Placeholder feature is very useful in cases where you need to extend same class into multiple classes and exclude that class from final css. This will reduce your code little bit. Let’s dive into code: Let’s say you have “icons” class which …

Continue Reading