.c1{
height: 300px;
width: 500px;
}
注意事项:
块级和行内标签
css样式 标签: display: inline-block
加上这个标签后行内标签具有了块级标签的特性,可以设置宽高了
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>用户注册title>
<style>
input[type='text']{
border: 1px solid red;
}
.c1{
display: inline-block;
height: 100px;
width: 300px;
border: 2px solid red;
}
style>
head>
<body>
<span class="c1">安娜span>
<span class="c1">安娜span>
body>
html>
<span style="display: block;">安娜span>
<div style="display: inline;">安娜div>
使用这个标签后行内标签具有块级标签的特性,块级标签的属性具有行内标签的属性
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>用户注册title>
<style>
.c1{
color: red;
font-size: 58px;
font-weight: 400;
font-family: Microsoft Yahei;
}
style>
head>
<body>
<div class="c1">安娜div>
<div style="display: inline;">安娜div>
body>
html>
text-align: center 水平方向居中
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>用户注册title>
<style>
.c1{
color: #00FF7F;
height: 100px;
width: 300px;
border: 2px solid red;
text-align: center;
}
style>
head>
<body>
<div class="c1">安娜div>
<div style="display: inline;">安娜div>
body>
html>
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>用户注册title>
<style>
.c1{
color: #00FF7F;
height: 100px;
width: 300px;
border: 2px solid red;
text-align: center;
line-height:100px;
}
style>
head>
<body>
<div class="c1">安娜div>
<div style="display: inline;">安娜div>
body>
html>
本来span标签两个是挨在一起的,使用向右浮动,就会一个显示在左边一个在右边
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>用户注册title>
head>
<body>
<span>安娜span>
<span style="float:right">伏伦斯基span>
body>
html>
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>用户注册title>
<style>
.c1{
float: left;
height: 100px;
width: 300px;
border: 2px solid red;
}
style>
head>
<body>
<div>
<div class="c1">div>
<div class="c1">div>
<div class="c1">div>
<div class="c1">div>
div>
body>
html>
浮动起来后,自己有多宽就占多宽。
如果让标签浮动起来后,就会脱离文档流。会使得父级div的样式无法显示,需要加上
<body>
<div style="background-color: blue">
<div class="c1">div>
<div class="c1">div>
<div class="c1">div>
<div class="c1">div>
<div style="clear: both;">div>
div>
body>
距离自己标签内部的距离
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>用户注册title>
<style>
.outer{
height: 300px;
width: 300px;
border: 2px solid red;
padding-top: 20px;
padding-left: 20px;
}
style>
head>
<body>
<div class="outer">
<div>你的眼里都是光div>
<div>真是那样吗div>
div>
body>
html>
padding: 20px;
按上右下左的顺时针方向的内边距大小
padding: 40px 30px 20px 10px;
当前标签与其他标签的距离
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>用户注册title>
head>
<body>
<div style="background-color:red; height:100px">你的眼里都是光div>
<div style="border: 2px solid blue; margin-top:30px">真是那样吗div>
body>
html>
body {
margin: 0
}
<div style="width: 200px; text-align: center;">安娜div>
区域居中,自己要有宽度+ margin- left:auto;margin-right:auto
. container {
width: 980px;
margin: 0 auto;
}
<div class=" container" >adfasdfdiv>