Mastering CSS Calc() for Dynamic Web Layout | Tips and Tricks

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 เม.ย. 2024
  • In this video, dive into the world of CSS Calc() function and discover how it can revolutionize your web design workflow. Calc() function in CSS is a powerful tool that enables dynamic calculations within stylesheets, allowing for precise control over the layout, sizing, and positioning of elements on a webpage.
    From adjusting font sizes based on viewport width to creating full-bleed sections effortlessly, CSS Calc() offers endless possibilities for creating responsive and visually appealing designs. Explore practical examples to apply CSS Calc() effectively in your projects.
    Like, share, and subscribe to our channel for valuable web development insights. Let's embark on this CSS adventure together!
    Related Topics
    -----------------------------------------------------
    - calc function in css
    - function in css
    - calc() lets you do some real CSS magic
    Subscribe and never miss a beat
    -----------------------------------------------------
    🔔 Subscribe for more videos like this: / @optimisticweb
    Learn at your own pace
    -----------------------------------------------------
    - Learn HTML - • HTML
    - Learn CSS - • CSS
    - Learn JavaScript - • JavaScript
    Connect, share, and grow
    -----------------------------------------------------
    - TH-cam: / @optimisticweb
    - X (Twitter): / optimisticweb
    - Instagram: / optimisticweb
    - Facebook: / optimisticweb
    - CodePen: codepen.io/optimisticweb
    #css #csscalc #csscalcfunction #cssfunctions #frontenddevelopment #webdevelopment #codingtips #webdevtutorial #csstutorial #csstips #cssmagic #cssshorts #cssforbeginners #csstricks #css3 #learncss #optimisticweb

ความคิดเห็น • 12

  • @rahulpatil3942
    @rahulpatil3942 3 หลายเดือนก่อน +3

    Great video and example as always ❤

  • @johnryder8464
    @johnryder8464 3 หลายเดือนก่อน +2

    Font clamp is my preferred method for typography.

    • @OptimisticWeb
      @OptimisticWeb  3 หลายเดือนก่อน +1

      Thanks for the feedback. Yes, the clamp() is better than calc() for typography and we already have a video (th-cam.com/users/shortsdr8G283fLzg) on that. As this particular video focuses on calc(), an example of working with the font sizes was shown.

    • @diegocerezo563
      @diegocerezo563 2 หลายเดือนก่อน +1

      I clamp for different sizes the make variables and finally calc this variables as I see fit

  • @voldemortvi4264
    @voldemortvi4264 3 หลายเดือนก่อน +1

    For typography i use clamp() property

    • @OptimisticWeb
      @OptimisticWeb  3 หลายเดือนก่อน

      Thanks for the feedback! Agreed, clamp() works better than calc() for typography. We have a dedicated video (th-cam.com/users/shortsdr8G283fLzg) on that. As this particular video focused on calc(), an example of working with the font sizes was shown.

  • @NeonStudiosOfficial23
    @NeonStudiosOfficial23 3 หลายเดือนก่อน +2

    👽✌️

  • @lineanimator8577
    @lineanimator8577 3 หลายเดือนก่อน +2

    I still dont understand that 50% - 50vw

    • @OptimisticWeb
      @OptimisticWeb  3 หลายเดือนก่อน +2

      That's indeed a tricky solution. Essentially, it calculates the difference between the width of the banner and the viewport, then sets negative left and right margins with half of that value. For example, if the viewport width is 1000px and the banner width is 600px, the difference would be 400px. This results in setting the left margin as negative 200px and the right margin as negative 200px. Hope this helps.

    • @kuoyulu6714
      @kuoyulu6714 2 หลายเดือนก่อน +1

      Was going to ask the same question, so this basically calculate how much less margin it will need left and right to touch the left and right side of the screen?

    • @OptimisticWeb
      @OptimisticWeb  2 หลายเดือนก่อน +1

      Yes, It calculates the distance between the viewport edges and the content and then applies a negative margin on both sides to break out of the layout.