Home Web Front-end CSS Tutorial How to add inner border in css3

How to add inner border in css3

Nov 19, 2020 am 11:52 AM
css3 inner border

How to add inner borders in css3: You can add inner borders by using the border attribute and box-sizing attribute, such as [box-sizing:border-box;]. The box-sizing attribute allows certain properties to be defined in a way to fit within a specified area.

How to add inner border in css3

The operating environment of this tutorial: windows7 system, css3 version. This method is suitable for all brands of computers.

css3 Add inner border

Related properties:

The border property allows you to specify the style and color of an element's border.

The box-sizing property allows you to define certain elements in a way to fit within a specified area.

(Learning video sharing: css video tutorial)

Grammar:

1

box-sizing: content-box|border-box|inherit:

Copy after login

Attribute value:

  • content-box This is the behavior of width and height specified by CSS2.1. Specifying the element's width and height (min/max properties) applies to the box's width and height. The element's padding and border layout and drawing specify the width and height except

  • border-box Specify the width and height (minimum/maximum attributes) to determine the element border. That is, specifying the width and height of an element includes padding and border. The width and height of the content are obtained by subtracting the border and padding from the set width and height respectively.

  • inherit Specifies the value of the box-sizing attribute, which should be inherited from the parent element

Code implementation:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<style>

div.container

{

    width:30em;

    border:1em solid;

}

div.box

{

    box-sizing:border-box;

    -moz-box-sizing:border-box; /* Firefox */

    width:50%;

    border:1em solid red;

    float:left;

}

</style>

</head>

<body>

 

<div class="container">

<div class="box">这个 div 占据了左边的一半。</div>

<div class="box">这个 div 占据了右边的一半。</div>

</div>

 

</body>

</html>

Copy after login

Achievement effect :

How to add inner border in css3

Related recommendations: CSS tutorial

The above is the detailed content of How to add inner border in css3. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to achieve wave effect with pure CSS3? (code example) How to achieve wave effect with pure CSS3? (code example) Jun 28, 2022 pm 01:39 PM

How to achieve wave effect with pure CSS3? (code example)

Use CSS skillfully to realize various strange-shaped buttons (with code) Use CSS skillfully to realize various strange-shaped buttons (with code) Jul 19, 2022 am 11:28 AM

Use CSS skillfully to realize various strange-shaped buttons (with code)

How to hide elements in css without taking up space How to hide elements in css without taking up space Jun 01, 2022 pm 07:15 PM

How to hide elements in css without taking up space

How to implement lace borders in css3 How to implement lace borders in css3 Sep 16, 2022 pm 07:11 PM

How to implement lace borders in css3

It turns out that text carousel and image carousel can also be realized using pure CSS! It turns out that text carousel and image carousel can also be realized using pure CSS! Jun 10, 2022 pm 01:00 PM

It turns out that text carousel and image carousel can also be realized using pure CSS!

css3 what is adaptive layout css3 what is adaptive layout Jun 02, 2022 pm 12:05 PM

css3 what is adaptive layout

How to enlarge the image by clicking the mouse in css3 How to enlarge the image by clicking the mouse in css3 Apr 25, 2022 pm 04:52 PM

How to enlarge the image by clicking the mouse in css3

Does css3 animation effect have deformation? Does css3 animation effect have deformation? Apr 28, 2022 pm 02:20 PM

Does css3 animation effect have deformation?

See all articles