CSS: The Obscure, Weird and Underutilized
Categories
- Advertising(70)
- Copywriting(36)
- Design(44)
- Development(20)
- Get to Know Our Work(7)
- In Conversation(3)
- Photography(7)
- SEO(10)
- Social Media(37)
- Video(3)
Archives
- July 2024
- March 2024
- February 2024
- January 2024
- December 2023
- October 2023
- July 2023
- June 2023
- May 2023
- April 2023
- March 2023
- February 2023
- January 2023
- December 2022
- November 2022
- October 2022
- June 2022
- May 2022
- April 2022
- March 2022
- February 2022
- January 2022
- November 2021
- October 2021
- September 2021
- August 2021
- July 2021
- June 2021
- May 2021
- April 2021
- March 2021
- February 2021
- January 2021
- September 2020
- August 2020
- July 2020
- June 2020
- May 2020
- April 2020
- March 2020
- February 2020
- December 2019
- November 2019
- October 2019
- September 2019
- May 2019
- April 2019
- March 2019
- February 2019
- January 2019
- December 2018
- November 2018
CSS: The Obscure, Weird and Underutilized
- Posted by IMT-Webdeveloper
- December 13, 2022
- in
- 0
- Comments Off on CSS: The Obscure, Weird and Underutilized
Calc()
Historically, CSS has not been considered a programming language because it was not able to perform calculations or run formulas. With the introduction of the calc function, developers are now able to add, subtract, multiply, divide, etc. for sizing and positioning elements. As an alternative to the standard unit of an element, developers can mix and match units to create interesting hacks. One popular hack among developers relates to typography. The example below provided by csstricks.com, makes a websites typography consistent on all screen sizes.
See the Pen
Untitled by CSS-Tricks (@css-tricks)
on CodePen.
Custom Variables
For many years CSS variables were considered risky and even shunned because they were not supported by all browsers. With Internet Explorer being put to bed and big browsers receiving much needed updates, developers can now breathe a sigh of relief knowing that CSS variables are safe. Developers do not need to worry about fallbacks anymore.
Creators can now set a reusable call within a stylesheet to keep things consistent throughout the site. Changes such as font style or colors can now be modified with a single line of code.
// Example of CSS Variable
:root {
–brandRed: #dc3232;
}
button {
background-color: var(–brandRed); //background is red
}
Rotate Y
Incorporating a rotating CSS element is always fun. Users become more engaged when an element has an animated effect. An example would be having a two-dimensional image on its Y axis. This would create an illusion that the image is three dimensional. This example is demonstrated on Aable Pest Control’s website aablepc.com. Viewers are able to hover over the different pests, creating an engaging and fun experience that the user will remember. The effect is done via the transform styling rule on hover.
.bugBox:hover > img {
transform: translateX(-100%) rotateY(-180deg);
}
Unset Rules
CSS can get messy on larger sites because developers must override rules set in place. When this occurs, developers will need to use an unset. An unset can be applied to individual rules such as colors and fonts. Many times, a clean slate is needed. In this instance, developers will need to “unset:all” to void previous rules and start fresh. Applying this to every element with an asterisk and !important tag will leave the website with no styling.
.page-contact h1 {
all: unset;
}* {
all: unset !important;
}
Letter Spacing
Users and clients will often fixate on fonts. Playing with font-family, size, color and weights are tricks that can spice up a site’s typography. An often-overlooked tool is letter spacing. Letter spacing is the space between letters. Spacing can be used to fill a page when there is limited content or make headings stand out more. It is important to know when to draw the line. A couple of pixels between every character may be a bit much. Instead, creators can use a fraction of a pixel or another unit as they allow decimals.
h1 {
letter-spacing: .5px;
}