web开发(3) 传说的盒模型之border_html/css_WEB-ITnose
大道至简
上一章节我们学会了padding的用法,padding是为我们的文本区域添加内边距,类似于礼品盒的泡沫区域(即保护区域),那么盒子都是有外边的硬纸壳的,这在我们的web开发中会有对应的属性吗?
答案很明显是有的,就是我们今天的主角border。请看下列代码:
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Border</title><style> div { width: 200px; height: 200px; background-color: red; border: 5px solid orange; }</style></head><body><div></div></body></html>
border.png
效果如图所示,橘黄色区域就是我们的border了。再来回想下代码border: 5px solid orange,里边到底是什么意思呢?这行代码等同于下列代码:
/*定义边框宽度*/border-width: 5px;/*定义边框样式*//*solid为实线、dashed为虚线、dotted为点线*/border-style: solid;/*定义边框颜色*/border-color: orange;
如果是分写的话,以上三条语句缺一不可,ok我们可以来分析下我们原来的那条语句了。
- 第一个参数是border-width
- 第二个参数是border-style
- 第三个参数是border-color
我们再来看看下边的代码:
border-top: 1px solid red;border-bottom: 1px solid red;border-left: 1px solid red;border-right: 1px solid red;
没错啊,我们还可以单独为某一个方向设置border,是不是很方便。
注意:我们在使用border的时候会发现盒子的面积变大了,没错的border是外嵌的,它的存在会影响宽高。
创造即永恒,喝茶去……

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.
