7 Amazing New CSS Techniques For 2019

This is the proper time to decide on internet development as a career possibility. similar to internet designers, internet developers conjointly fascinated with ways in which to do new CSS techniques and push the boundaries of what CSS will do.


Here, square measure going to} take a glance at a number of the new CSS techniques and full specifications that are creating their method into inventive styles. you'll be able to management nearly any side of a style by a well-described CSS. Also, it will enhance a far better robust|an improved} overall user experiences—with cleaner and more consistent code.

1. Initial Letter

Initial letter could be a CSS property, property that selects the primary letter of the part and specifies the quantity of lines occupied by the letter. most frequently it's employed in medium and data sites, news sites, wherever the primary letter of the paragraph is with a lot of more than the remainder of the content.
The initial-letter property mechanically adjusts each the quantity of lines required to make the stylised drop cap and also the font size. Initial-letter approves the subsequent values:

  • Refers to what number lines the letter occupies during which negative values don't seem to be accepted;
  • Normal is helpful if you would like to reset the worth if it can be transmitted from the cascade and no scaling result applied to the primary letter;
  • Determines the quantity of lines during which the letter ought to sink once its size is planned. The values should be bigger than zero, and if the worth isn't specific, the scale price is duplicated, floored to the closest positive whole number;


The first-letter pseudo-element is wont to choose characters which will be formatted as initial letters. The ::first-letter pseudo-element doesn't choose the primary letter of the part that has the display: inline, however solely works on components that have a show price of block, table-cell, table-caption, or list-item.

<!DOCTYPE html>
<html>
<head>
<style>
p {
 font-family: Serif;
 font-size: 20px;
 margin-bottom: -15px;
}
h1 {
 font-family: Sans-serif;
 font-size: 3.1em;
 color: black;
}
body {
 padding: 10px;
}
div {
 width: 550px;
 line-height: 25px;
}
p:first-of-type:first-letter {
 background-color: black;
 color: white;
 float: left;
 font-size: 50px;
 margin-right: 10px;
 margin-top: 7px;
 padding: 18px;
 box-shadow: 0 0 10px -2px black;
}
</style>
</head>
<body>
<h1>About initial letter</h1>
<div>
<p>Only one who devotes himself to a cause with his whole strength and soul can be a true master. For this reason mastery demands all of a person"</p>
<p>"Concern for man and his fate must always form the chief interest of all technical endeavors. Never forget this in the midst of your diagrams and equation"</p>
</div>
</body>
</html>
Initial letter

2. Variable Fonts

Variable fonts represent a replacement set of options outlined as a part of the OpenType specification and permit font files to contain multiple variations of a font in an exceedingly file, known as variable font. In follow, it permits you to access the variables contained within the font file with only 1 @ font-face reference. Also, variable fonts enable functions like transitioning font designs, custom font designs and invigorating.The good thing about mistreatment the variable font is that you just have access to the total vary of accessible designs, weights and widths.

  • Variable fonts outline their variations through axes of variation and there ar five customary axes:
  • ital: italic axis works otherwise as a result of it's enabled or disabled, there's no middle. the worth is set mistreatment the font-style CSS property. Also, by introducing font-synthesis: none, can forestall browsers applying accidentally the variation axis and a synthesized italic
  • wght: controls the font’s weight and also the worth is set mistreatment the font-weight CSS property.
  • wdth: controls the font’s dimension and also the worth is set mistreatment the font-width CSS property.In CSS mistreatment the font-stretch property, we will set the font dimension with proportion values and if we have a tendency to provide a worth that's outside the font-encoded domain, the browser makes the font at the nighest allowed worth.
  • opsz: optical filler refers to the follow of adjusting the font’s optical size and also the worth is set mistreatment the CSS font-optical-sizing.Optical size values ar mechanically applied counting on the font size, however is manipulated mistreatment the font-variation-settings.When mistreatment font-optical-sizing, the admitted values ar motorcar or none, and once mistreatment font-variation-settings, a numeric worth is provided.
slnt: controls the slant of the font and also the worth is set mistreatment the font-style CSS property.It is variable by being expressed as a numerical vary, and this enables the font to be varied anyplace on that axis.
Using variable fonts with @font-face – once mistreatment variable fonts on the net, this involves shaping @ font-face rules that indicate variable font files.Here ar two links that enable you to seek out variable fonts: axis-praxis.org and v-fonts.com.
<!DOCTYPE html>
<html>
<head>
<title>About variable fonts</title>
</head>
<style>
@font-face {
  font-family: 'Avenir Next Variable';
src: url('https://cdn.rawgit.com/Monotype/Monotype_prototype_variable_fonts/f8067a0e/AvenirNext/AvenirNext_Variable.ttf') format('truetype');
}
html {
  font-family: 'Avenir Next Variable', sans-serif;
}
p {
  font-variation-settings: 'wght' 630, 'wdth' 88;
}
</style>
<body>
<h1>About variable fonts</h1>
<h2>About variable fonts</h2>
<p>
 "Any intelligent fool can make things bigger and more complex… It takes a touch of genius – and a lot of courage to move in the opposite direction."
</p>
</body>
</html>
Variablefonts
3. Logical Properties and Values
Logical Properties and Values may be a CSS module that introduces logical properties and values that make it potential to manage the appearance through logical directions and dimension mappings.Logical properties and values use the terms like block and inline to elucidate the direction throughout that they flow.The Logical Properties and Values specification characterizes mappings for physical values in their logical relations.
The inline dimension – is that the dimension thereon a text line is written inside the shape of writing used. So, throughout a random English document, the text is horizontal, from left to right, in another Arabic document, writing is to boot horizontal but from right to left and if we've got an inclination to require into thought a Japanese document, the inline dimension is presently vertical as a results of the writing mode run vertically.
The block dimension – corresponds to the order throughout that the blocks ar displayed on the page. In English and Arabic they are dead vertically, whereas in any vertical writing mode they are dead horizontally.
<!DOCTYPE html>
<html>
<head>
<style>
html {
  font: 20px Sans-serif;
}
body {
  padding: 25px;
  background-color: lightyellow;
  color: black;
}
.box {
  border: 4px solid black;
  border-radius: 20px;
  padding: 20px;
  margin: 12px;
}
.one {
  block-size: 100px;
  inline-size: 200px;
}
.two {
  height: 100px;
  width: 200px;
}
</style>
</head>
<body>
</div>
<div id="container">
<div class="box one">
  My block-size is 100 pixels, my inline-size 200px.
</div>
<div class="box two">
  My height is 100 pixels, my width 200px.
</div>
</div>
</body>
</html>
Logical properties and values
4. Scroll Snapping
The scroll-snap-type CSS property determines the rigidity with which attachment points are applied to the scroll container.In other words, it lock the viewport to certain elementsor locations after the user has finished scrolling.It is an excellent way to display image galleries.Previously, it could be used with JavaScript, but thanks to the new CSS Scroll Snap module, the effect can be controlled in CSS.Scroll snapping is done by defining the parent / container element and children in the container that will snap according to the rules defined within the container.Scroll-snap-type property is the most important property that applies to the container element.Defines the scroll snap axis x, y, block, inline or both and the scroll snap strictness none, proximity or mandatory.
<!DOCTYPE html>
<html>
<head>
<style>
html, body, .C {
  height: 50%;
}
.C {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-flow: column nowrap;
  font-family: arial;
}
.container {
  display: flex;
  flex: none;
  overflow: auto
}
.container.x {
  width: 70%;
  height: 150px;
  flex-flow: row nowrap;
}
.container.y {
  width: 256px;
  height: 256px;
  flex-flow: column nowrap;
}
.y.mandatory-scroll-snapping {
  scroll-snap-type: y mandatory;
}
.x.proximity-scroll-snapping {
  scroll-snap-type: x proximity;
}
.container > div {
  text-align: center;
  scroll-snap-align: center;
  flex: none;
}
.x.container> div {
  line-height: 128px;
  font-size: 64px;
  width: 100%;
  height: 128px;
}
.y.container> div {
  line-height: 256px;
  font-size: 128px;
  width: 256px;
  height: 256px;
}
.y.container>div:{
  line-height: 1.4;
  font-size: 80px;
}
.container >div:{
  background-color: white;
}
.container >div:{
  background-color: white;
}
</style>
</head>
<body>
<div class=".C">
<div class="container x mandatory-scroll-snapping" dir="ltr">
<div>Scroll Snapping</div>
<div>2</div>
<div>3</div>
<div>4</div>
</div>
<div class="container y mandatory-scroll-snapping" dir="ltr">
<div>About Scropp Snapping</div>
<div>2</div>
<div>3</div>
<div>4</div>
</div>
</div>
</body>
</html>
Scroll snapping

5. Grid Level two and Subgrid

The level two specification contains everything in Level one and a few new options. Level two of the grid specification creates the subgrid feature of CSS Grid.In the following lines, we are going to verify the subgrid feature because it is presently elaborate within the Editor’s Draft of Grid Level two.So, you'll be able to build grids after you use the Grid layout possibility, a grid part will be reworked into a grid instrumentality by setting display: grid on that.In the example below, I actually have Associate in Nursing item that has three column tracks of the grid, could be a instrumentality grid with three column tracks, and these don't don't line up with the tracks of the parent.

<!DOCTYPE html>
<html>
<head>
<title>CSS Grid Level 2 - subgrid</title>
</head>
<style>
body {
  margin: 20px;
}
.one {
  background-color: black;
  color: white;
  border-radius: 20px;
  padding: 20px;
  font-size: 120%;
}
.A .one {
  background-color: lightgrey;
}
.GRID {
  display: grid;
  grid-gap: 10px;
  grid-template-columns: 3fr 1.5fr 2fr 1fr 1fr 2fr;
  background-color: white;
  color: black;
  margin: 1.5em 0;
}
.A {
  padding: 0;
  grid-gap: 15px;
  grid-column: auto / span 4;
  display: grid;
  grid-template-columns: 3fr 1.5fr 1.5fr;
}
</style>
<body>
<div class="GRID">
<div class="one 1">1</div>
<div class="one 2">2</div>
<div class="one 3">3</div>
<div class="one 4">4</div>
<div class="one 5">5</div>
<div class="one 6">6</div>
<div class="one 7">7</div>
<div class="one 8">8</div>
<div class="one A">
<div class="one 9">9</div>
<div class="one 10">10</div>
<div class="one 11">11</div>
<div class="one 12">12</div>
<div class="one 13">13</div>
<div class="one 14">14</div>
</div>
<div class="one 15">15</div>
<div class="one 16">16</div>
<div class="one 17">17</div>
<div class="one 18">18</div>
<div class="one 19">19</div>
<div class="one 20">20</div>
</div>
</body>
</html>
Grid level 2 and subgrid
Being associate open supply project, you'll see on GitHub however the work evolving within the CSS cluster. the event of browser specifications and implementation could be a circular method. thus you'll watch however this subgrid feature is progressing and of rising browser implementations.

6. Use CSS to check Browser Support

CSS has developed how to check browser support for brand spanking new options. Basically, raise a matter to seek out out if the browser accepts a selected CSS feature. means|this manner|this fashion} makes the new options use during a safe and epigrammatic way.When victimisation any new CSS feature, you wish to visualize if the browser supports that feature.On this line, it's counseled that you just consult the information on caniuse.com, wherever you'll import the information for your location.
Use CSS to test browser support
The @supports CSS permits you to specify declarations that rely upon browser support for CSS options, this being referred to as a feature question. This rule are often written at the highest of the code or it should be nested within the other conditional cluster at-rule.
@supports (display: grid) {
  div {
    display: grid;
  }
}
7. Syntax enhancements For Media Queries – Level four
The Media Queries Level four specification contains some enhancements to the syntax to form media queries victimization options that have a variety kind like height and breadth.
@media (max-width: 20em) 
We can attempt a breadth between 2 random values victimization min- and max-

@media (min-width: 20em) and (max-width: 35em)
For a more robust understanding, within the example higher than we would like to mention that the breadth is bigger than or adequate to 20em and smaller or adequate to 35em

Conclusion
Website developers ought to bear in mind of any new CSS techniques and apply them in future comes. they'll raise their work standards and customers are going to be happy with the improved web site look.

Post a Comment

0 Comments