iT邦幫忙

2021 iThome 鐵人賽

DAY 4
0
Modern Web

Learn & Play JavaScript -- Entry-Level Front-End Web Development系列 第 4

#4 CSS Box Model, Selector, Absolute/Relative Position

  • 分享至 

  • xImage
  •  

CSS Box Model

  • Frame & tag design: <div style="padding:10px;width:300px;border:1px dashed blue;margin-top:5px;margin-bottom:5px"
    • “dashed” can be changed into “solid” for designing solid lines.
      https://ithelp.ithome.com.tw/upload/images/20210903/20130362OMMaBEWinC.png

Selector

p {
    color:green
}
  • Selector: apply to

    • any element of a specific type, e.g. font size <h1>.
    • From the picture above, the selector is “p.”
  • Property

    • Properties change the elements of your HTML.
    • From the picture above, the property is “color.”
  • More examples of selectors

<style type="text/css">
.title{.............}
.content{............}
.keyword{.............}
</style>

Meanwhile, we have to insert <class=”title/content/keyword”> into the division where we need the selector. This is my selector:
https://ithelp.ithome.com.tw/upload/images/20210903/20130362DdiMj1ZTT3.png

  • With selector: give different styles, content, keywords a responding selector, so that we can change the same design at every division all at once.
  • Without selector: we have to change the design one by one at each division.

CSS Position

  • Absolute Position
    • often used by designing a notification area.
.box{
	position:absolute;right:0px;top:0px;
	width:100px;height:100px;background-color:green
}

https://ithelp.ithome.com.tw/upload/images/20210903/20130362thsKJJxqsa.png

  • Relative Position
    • The box will be positioned basing on where we input the <div class="box"></div>.
      https://ithelp.ithome.com.tw/upload/images/20210903/20130362j7ygkUgQGB.png

    • Another example of a relative position in a sentence.
      https://ithelp.ithome.com.tw/upload/images/20210904/20130362DvTWJfuQOH.png

Final Web Design

https://ithelp.ithome.com.tw/upload/images/20210904/20130362we6oImIxjP.png


Music of Today: Leave the Door Open by Bruno Mars, Anderson .Paak, Silk Sonic

Yes


Like/Share/Follow

If you guys find this article helpful, please kindly do the writer a favor — LIKE this article./images/emoticon/emoticon12.gif
Feel free to comment and share your ideas below to learn together!


上一篇
#3 CSS Introduction x Foodie
下一篇
#5 Types of CSS Selector
系列文
Learn & Play JavaScript -- Entry-Level Front-End Web Development30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言