반응형
반응형

https://medium.com/@anirudh.munipalli/10-powerful-css-properties-that-every-web-developer-must-know-e5d7f8f04e10

You probably never heard of them, but you will love them once you know.

CSS.

A language which is responsible for nearly every website in the world.

With so many properties, CSS is pretty huge. Finding good properties among them is like trying to read a binary file by yourself (pls don’t try it).

Which is why I have done that for you (the CSS, not the binary).

Here are 10 properties that you may not use much, or have never heard of, but will love once you know them.

Photo by Markus Spiske on Unsplash

Custom Scrollbars

Let’s change the width and color of the scroll bar. Also, let’s make it a little round as well.

Below are the parts of a scroll bar.

What the different parts of a scroll bar are | Image by Author

We use ::-webkit-scrollbar to change the properties.

/* Set the width of the scroll bar*/
::-webkit-scrollbar{
    width: 10px;
}
/* Change the track to a blue color and give a round border */
::-webkit-scrollbar-track{
    background-color: blue;
    border-radius: 10px;
}
/* Making the thumb (which shows how much you've scrolled) a gray color
  and making it round */
::-webkit-scrollbar-thumb{
    background: gray;
    border-radius: 10px
}
/* A dark gray color when hovered overn */
::-webkit-scrollbar-thumb:hover{
    background: darkgray;
}

The result of the code | Image by Author

Note: This is a non-standard property, and without -webkit-, it will not work.

Cursors

Change how the cursor looks when you mouse over an element.

/* An element with class 'first' */
.first{
    cursor: not-allowed;
}
/* An element with class 'second' */
.second{
    cursor: zoom-in;
}
/* An element with class 'third' */
.third{
    cursor: crosshair;
}

Result of the above code. The cursor on different elements | Image by Author

Scroll behavior

The scroll behavior can make a smooth scroll, to make transition from one section to another smoother.

Add this simple line and see the effect for yourself.

html{
  scroll-behavior:smooth;
}

Instead of simply snapping the page from one section to another, it scroll up/down to the section. See the effect here.

Accent color

Change the color for user interface, such as form controls and checkboxes.

Accent color demo | Image by Author

See how the color of the check box and radio button is blue, instead of the default (and boring) gray.

input{
  accent-color: blue;
}

That’s all. You can use selectors to make some inputs blue, some red and some green.

And this doesn’t change the color of the text, so you can mess around with the colors and experiment. The UI color is under our control.

Aspect Ratio

When building responsive components, constantly keeping check on the height and width might be a headache, as you have to maintain aspect ratios. Videos, and Images may appear stretched sometimes.

That is why we can use the aspect ratio property. Once you set the aspect ratio value, and then set width, the height is set automatically. Or the other way around.

/* An elment with class example */
.example{
    /* Setting the aspect ratio */
    aspect-ratio: 1 / .25;
    /* Upon setting width, height is automatically set */
    width: 200px;
    /* Border is not required, but it is here just to see the effect. */
    border: solid black 1px;
}

Now that we set the width, we will get the height equal to 125 px automatically, to maintain the aspect ratio. This is very useful for responsive behavior.

The result when the CSS is applied to the HTML | Image by Author

Box Reflect

This allows us to create reflections of an component below it.

For this demo, I used an SVG wave image, that I got using this website.

/* An element with class name 'example */
.example{
    /* The reflection will appear below. Other possible values are above | left | right */
    -webkit-box-reflect: below;
}

This creates a reflection below the SVG.

Box reflection below the image | Image by Author

We can also offset the reflection a bit.

/* An element with class name 'example */
.example{
    /* The reflection will appear below. Other possible values are above | left | right */
    -webkit-box-reflect: below 20px;
}

The reflection with offset | Image by Author

Also, I would like it to fade out a bit. We can use a gradient for that.

/* An element with class name 'example */
.example{
    /* The reflection will appear below. Other possible values are above | left | right */
    -webkit-box-reflect: below 0px linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,.5));
}

This gives a nice reflection.

The resulting reflection | Image by author

This is a non-standard property supported by most major browsers (except Firefox).

Check if browser supports a property

How to check if a particular property is supported in CSS.

/* Check if browser supports display: flex */
@supports (display: flex){
    /* If it does, set the display to flex */
    div{
        display: flex
    }
}

While the above example will always be supported by major browsers, non-standard properties (such as custom scroll bars and box-reflections) might not be supported by some.

Remember to put the condition in () parenthesis.

If you put the not keyword, then it will work if the property is not supported.

@supports not (display: flex){/* If not supported *}

Masks

You can use an Image mask in CSS.

/* An object with class example */
.example{
    /* Setting the mask from a URL */
    -webkit-mask: url(YOUR URL);
    mask: url(YOUR URL);
}

In the mask image, the white represents the mask and black is the area to be clipped.

Filter

You can add amazing filters to your images using CSS. Filters are something we see in every photo sharing app, and now, let’s see how easy they are to implement

img{
    filter: /*YOUR VALUE */;
}

There are many filters available. You can blur, brighten and saturate filters. You can make the image grayscale, change it’s opacity, invert the colors, and more.

The normal image (left), blurred image(middle) and high contrast image(right) | Image by Author | Photo of grass by Author

A brightened image (left), a grayscale image (middle) and a hue rotated image (right) | Image by Author | Photo of grass by Author

See this page for more details.

Backdrop effects

You can add a good looking filter to the area behind an image using backdrop-filter.

All the properties of filter are available here. This is in other words just a filter to apply to the background.

<div class="image">
    <div class="effect">
        backdrop-filter: blur(5px);
    </div>
</div>

<style>
.image{
    background-image: url(YOUR URL);
    background-size: cover;
    width: 400px;
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.effect{
    font-size: x-large;
    color: white;
    font-weight: 800;
    background-color: rgba(255, 255, 255, .3);
    backdrop-filter: blur(5px);
    padding: 20px;
}
</style>

This makes an effect like this:

Result of the code | Image by Author

And with that, you now know 10 new properties of CSS. You can make your website look very professional.

If you like this article, show your support by:

  1. Clapping
  2. Following for content about CSS, HTML, JS, Python and AI.
  3. Responding to this article telling your favorite property.
  4. Or do all of the above 3 😃
반응형
반응형

도요타는 목표를 절대 개인에게 주지 않고 그룹에게 부여한다.
도요타에서는 지혜는 무한하다는 생각으로
사람들을 못살게 구는 일을 해왔다.
100엔이 드는 일을 50엔으로 하는 일은
개인은 못하지만 팀은 할 수 있다.
- 와까마츠 요시히토, 일본 CulMan 컨설팅 대표


‘빨리 가고 싶다면 혼자가라. 그러나
멀리 가고 싶다면 함께 가라’는 아프리카 속담이 있습니다.
탁월한 성과를 창출하는 조직은 늘 팀을 개인보다 우선합니다.

맨유의 퍼거슨 감독은 ‘팀이 가장 뛰어난 선수다’라고 말했고,
최근 오케스트라 지휘자로 나선 첼리스트 장한나 역시
‘오케스트라가 최고의 악기다’라고 말합니다.

함께하면 더 많은 것을 이룰 수 있다는데
팀(TEAM : Together Everyone Accomplishes More)의 묘미가 있습니다.

반응형
반응형

저는 현재 프로 골퍼
여섯 명의 심리 상담을 맡고 있는데,
그들에게 입버릇처럼 되풀이하는 조언이 있습니다.
"대회에 나가서 기분 좋게 플레이하라. 그래야
좋은 스코어를 낼 확률이 높아진다."
스포츠는 '분위기'가 승부를 결정짓는 경우가
많습니다. 오타니 선수도 기분 좋게 타석에
들어서면 홈런을 칠 확률이 높아지고,
기분 좋게 마운드에 오르면
승리 투수가 될 확률이
높아집니다.


- 고다마 미쓰오의 《오타니 쇼헤이의 쇼타임》 중에서 -


* '기분에 따라 승패가 갈린다.'
스포츠 선수에 국한된 조언은 아닙니다.
전투기 조종을 하는 조종사들도 그날의 기분이
생사 여부에 영향을 미친다고 합니다. 찰나의 순간이
운명을 갈라놓기 때문입니다. 그래서 특히 군인이나
소방관 등 생명에 직접적인 영향이 있는 직업군과
그 배우자들은 정서 관리에 힘써야 합니다.
그래야 승리 투수가 될 수 있습니다.

반응형

'생활의 발견 > 아침편지' 카테고리의 다른 글

지금, 여기, 나 자신!  (0) 2023.08.30
에너지와 에너지의 화학반응  (0) 2023.08.30
80대 백발의 할머니  (1) 2023.08.28
몽골 초원의 밤  (0) 2023.08.26
나의 인생 이야기, 고쳐 쓸 수 있다  (0) 2023.08.25
반응형

2023-08-27, 서울역사박물관, 경복궁 나들이
 
서울역사 박물관에서 상하이 전시보고, 파파이스에서 치킨치킨. 
 
교보문고에서 책 쇼핑 후 경복궁.  "괴물이 사는 궁궐" 책 속 괴물 찾아보기 



 
https://www.youtube.com/watch?v=9Ivcg-8YH_Q 

 

반응형
반응형

"늙는다는 것은
흰머리가 나는 때를 말해요."
알렉스는 마침내 말을 꺼냈으나
옆에 앉은 도로시 할머니를 슬쩍 쳐다본다.
80대인 도로시 할머니는 머리 전체가 백발이다.
알렉스는 당황해서 붉어진 얼굴을 손으로 가린다.
도로시 할머니는 알렉스의 등을 토닥거리고는
이렇게 말한다. "내겐 19살 때 흰머리가 난
자매가 있단다. 그러니까 흰머리가 난다고
늙었다고 할 수는 없지. 그리고 염색을
하는 사람들도 있으니까"


- 크리스토퍼 필립스의 《소크라테스 카페》 중에서 -


* 백발이 되는 요인은 많습니다.
자연스러운 노화의 현상이기도 하지만
정신적 충격으로 하룻밤 새 머리가 하얀 백발이
되었다는 일화도 있습니다. 스트레스로 흰머리에
탈모까지 겹치는 경우도 많고 유전적으로 일찍이
백발이 오는 경우도 흔합니다. 어떤 경우이든
흰머리를 많이 발견하게 된다면 그 기회에
자신의 삶을 들여다보는 것도 좋습니다.
마음마저 백발에 흔들지 않도록.
더 젊은 생각을 갖도록.

반응형
반응형

우리의 슬로건 중 하나는
‘세상이 오른 쪽으로 갈 때, 우리는 왼쪽으로 간다.’입니다.
우리는 언제나
다른 사람들이 이미 하고 있는 것과 반대로 하려고 합니다.
- 찰스 던스톤, 토크토크 텔레콤 회장


일반적인 사회적 통념이 잘못된 경우가 많습니다.
인류의 가장 위대한 혁명은 세상에서 널리 인정받는 주장과 믿음에
의문을 제기한 위대한 사상가들로부터 시작되었습니다.
코페르니쿠스는 태양이 지구를 돈다는 패러다임에 반기를 들었습니다.
고정관념과 사회적 통념을 버리는데서 새로움이 창조됩니다.

반응형

+ Recent posts