Skip to main content

CSS Tricks and Techniques 2018

As time goes by, CSS is becoming more and more powerful and nowadays it allows a lot of possibilities. This article is a compilation of fresh, advanced tips and techniques to master your CSS skills.

Website Development Company Lucknow
Software and Website Development Company Lucknow

Using SVG for icons
SVG is supported by all modern browsers and scales well for all resolution types, so there’s no reason to continue using .jpg or .gif images for icons. Note the use of the background-size property to scale the background image on the on container size.
.logo {
  display: block;
  text-indent: -9999px;
  width: 100px;
  height: 82px;
  background: url(kiwi.svg);
  background-size: 100px 82px;
}
Fixed table layouts
A widely supported but surprisingly little-known property which changes the way the tables are rendered and gives you a sturdier, more predictable layout.
table {
  table-layout: fixed;
}
Curve text around a floated image
The shape-outside is a CSS property that allows geometric shapes to be set, in order to define an area for text to flow around.
.shape {
  width: 300px;
  float: left;
  shape-outside: circle(50%);
}
Intrinsic Ratio Boxes
Using 20% for padding makes the height of the box equal to 20% of its width. No matter the width of the viewport, the child div will keep its aspect ratio (100% / 20% = 5:1).
.container {
  height: 0;
  padding-bottom: 20%;
  position: relative;
}

.container div {
  border: 2px dashed #ddd;  
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  width: 100%;
}
Color fade on hover
A very easy way to make your links (or any other element) look better.
a {
 color: #000;
 -webkit-transition: color 1s ease-in; /*safari and chrome */
 -moz-transition: color 1s ease-in; /* firefox */
 -o-transition: color 1s ease-in; /* opera */
}

a:hover { 
 color: #c00;
}
Style broken images
Broken images never look good, but it happens every now and then that one or two images on your site are broken. Using some advanced CSS, it is possible to style broken images and provide custom error messages to your visitors.
img {  
  min-height: 50px;
}

img:before {  
  content: " ";
  display: block;

  position: absolute;
  top: -10px;
  left: 0;
  height: calc(100% + 10px);
  width: 100%;
  background-color: rgb(230, 230, 230);
  border: 2px dotted rgb(200, 200, 200);
  border-radius: 5px;
}

img:after {  
  content: "\f127" " Broken Image of " attr(alt);
  display: block;
  font-size: 16px;
  font-style: normal;
  font-family: FontAwesome;
  color: rgb(100, 100, 100);

  position: absolute;
  top: 5px;
  left: 0;
  width: 100%;
  text-align: center;
}
Empty and not empty attribute selectors
CSS3 makes it easy to apply different styles to an element, depending on whether a data-* attribute is empty or not. Have a look at the HTML code below:
<div data-attr="">
</div>

<div data-attr="value">
</div>
And now, our CSS, with specific styling for any div element with an empty data-attr attribute:
div {
  border: 1px solid gray;
  height: 100px;
  margin: 10px;
  width: 100px;
}

/* Empty attribute selector */
div[data-attr=''] {
  background: red;
}

/* Not empty attribute selector */
div:not([data-attr='']) {
  background: green;
}
Comma-Separated Lists
A little snippet to display an unordered list as a comma-separated list. Note the use of :not(:last-child) to ensure that the last list element won’t be followed by a comma.
ul > li:not(:last-child)::after {
  content: ",";
}

Source: catswhocode

Comments

  1. This is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article.Best Website Design and Development Company in Bangladesh

    ReplyDelete
  2. Very informative article, which you have shared here . After reading your article I got very much information and it is very useful for us. I am thankful to you for sharing this article here.It Staffing Agency in USA

    ReplyDelete
  3. Hi dear,

    Thank you for this wonderful post. It is very informative and useful. I would like to share something here too.Our highly professional team provide complete IT solutions that specializes in custom mobile and web application development. Call us at (+91) 9001721837.


    mobile app development


    ReplyDelete

Post a Comment

Popular posts from this blog

what is erp software?

ERP software is a comprehensive suite of business software that helps organizations manage their operations more effectively. It includes modules for accounting, sales, customer management, inventory management, and more. ERP software is often used by large organizations with multiple locations, thousand or more employees, and complex operations. What are the benefits of using ERP software? ERP software can be a valuable asset for businesses of all sizes. Here are some of the benefits you may experience when using an ERP system: Improved Efficiency: ERP systems can help businesses become more efficient and organized. They can help identify and track data across multiple systems, and they can help businesses manage large amounts of information in a more organized and accessible way. Improved Customer Service: ERP systems can help businesses improve their customer service by tracking customer data and providing customer service representatives with the information they need to

how to use erp software

Introduction to ERP software ERP software is a comprehensive suite of software applications used to manage an organization's business processes. ERP software can help businesses automate and manage a wide range of business processes, including financial management, human resources, procurement, and marketing. ERP software has been widely used in organizations of all sizes, and is often seen as a key to success in today's business world. By automating business processes, ERP software can help businesses reduce costs, improve efficiency, and increase profits. In this article, we will provide a brief overview of what ERP software is, and how it can benefit your business. We will also provide a few tips on how to choose the right ERP software for your organization, and how to implement it successfully. so that your business can take advantage of the benefits that ERP software can provide. Benefits and use of ERP software There are many benefits to using ERP software, includi

ERP Software

1. What are the benefits of using an ERP software for businesses? An ERP software can improve efficiency and accuracy of business operations by automating and consolidating various business processes. Additionally, an ERP system can help organizations to better manage inventory, customer information, and financial data. Additionally, an ERP software can also help businesses to better understand their customer needs, and to develop and implement strategies to better serve their customers. In addition, an ERP system can help businesses to better manage and optimize their resources, and to improve communication and collaboration between various departments within an organization. 2. What are some of the best ERP software options for small businesses? There are many great ERP software packages for small businesses. Some of the most popular options include: 1 QuickBooks – This software is ideal for small businesses who need a simple and easy to use accounting system. It has a ran