CSS is becoming more and more powerful every passing day. It helps the web designers to design a visually stunning website. There are some advanced CSS tricks and techniques that are beneficial in front end development.
Vertically align the elements with Flexbox
Centering a text or element vertically is quite difficult for the front end developers. But display: flex property in CSS3 specification makes it easy for the developers.
Here is the code for aligning the elements vertically:
Output of the code is as follows:
Use SVG for images and logos
SVG is now supported by all modern browsers. For good resolution, its recommended to the front end developers to use the SVG instead of PNG and JPG.
Code below represents how to use SVG format for logos and images in CSS:
background-size: 100px 82px;
CSS variables are used to avoid the code redundancy. Once we declare the css variables, we can use them again and again. CSS variables are very useful for front end developers.
Consider the CSS below:
Variables are declared by giving them name preceded by two dashes. In the above example, the main color, background color, and base padding are declared.
To use variables, use the var() function as shown in the above example.
Truncate Strings in CSS
Nowadays web designers or front end developers face a common problem when text is too long for its div. We can truncate the text in CSS3.
See the code below that helps to tackle that problem:
hii, this is long text which needs to truncate
CSS of h1 tag defines a fixed width and prevents the text from overflowing the container.
automatically adds ellipsis at the end of the text in order to indicate that text is truncated
See the output here :
This text box shows the truncated text. You can drag the div to see the proper text like this:
PHP programming is a valuable skill that a programmer can have. Let StudySection help you out with proving your programming skills through its PHP certification. StudySection provides beginner as well as expert-level certifications in PHP programming to prove your level of skills in PHP programming.