Intro to CSS: How To Add Border

作者: 此之木 | 来源:发表于2019-04-14 09:36 被阅读85次

    When we open any web page, almost all of them have unique backgrounds. Background can let people feel the personality of the brand.

    For some website, the web page also include a few borders, which make the page content more organized.

    Today, I am going to show you how to add border and background to your web page.

    Step One: Create a simple HTML web page

    No matter what, you always have to create a web page first. Since I love cooking, so I build a Love Cooking and Food blog page.

    The HTML part is:

    In the <body> part, I add a page header, a search bar, a short navigation which include four parts:"Home", "Homemade Recipes", "Food Photos" and "Diet Style". Each part should has hyperlinks to another page, but I don't have another page yet, so I just keep them here.

    Then, I write some simple text about this site and use <div> tag to block all the paragraphs for the CSS purpose.

    The outcome is just a all black text web page:

    Step Two: Write CSS file includes change color, add border and background

    After I finish the HTML part, now let's start the fun part!

    I want to start from the simple part: change the text color. Therefore, I go to the Color Picker to select the color code I want and to add into all the selector property values. For example, I want the paragraph texts are grey, so the code will be p{color: #2E4053;}.

    Then, I want to add a big border to include all the paragraphs. According to the course, border on CSS has three different parts: width, color and style (dash/solid). I put the value for each part to create the border: div{border: 2px solid orange;}

    Finally, I want to have a background on the page. So, I add the background image url in the body selector. Since I want the image fully cover the web page, so I put background-repeat with no-repeat, and background-size with cover.

    Step Three: Link the CSS file to HTML

    I link the CSS file to HTML page, so the web page can make changes.

    The final web page will look like:

    相关文章

      网友评论

        本文标题:Intro to CSS: How To Add Border

        本文链接:https://www.haomeiwen.com/subject/vetqwqtx.html