当前位置: 首页 > news >正文

Javaweb之css

css的三种引入方式

1内行式

2.内嵌式

3.外部样式表

内行式和内嵌式

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>input{border: 1px solid green;width: 60px;height: 40px;background-color: aquamarine;color: black;font-size: 22px;font-family: '行书';border-radius: 5px;}</style></head>
<body><!-- --><!-- <input  type="button" value="按钮"style="border: 1px solid green;width: 60px;height: 40px;background-color: aquamarine;color: black;font-size: 22px;font-family: '行书';border-radius: 5px;"> --><input type="button" value="按钮"><input type="button" value="按钮"></body>
</html>

外部样式表

一个css的文件

input{border: 1px solid green;
width: 60px;
height: 40px;
background-color: aquamarine;
color: black;
font-size: 22px;
font-family: '行书';
border-radius: 5px;
}

代码如下:

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><link href="css/btn.css" rel="stylesheet">
</head>
<body><input type="button" value="按钮">
<input type="button" value="按钮">
<input type="button" value="按钮">

选择器

1元素选择器

2id选择器

3class选择器

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>#六花{border: 1px solid green;width: 60px;height: 40px;background-color: aquamarine;color: black;font-size: 22px;font-family: '行书';border-radius: 5px;}</style> --><!--
元素选择器<style>input{border: 1px solid green;width: 60px;height: 40px;background-color: aquamarine;color: black;font-size: 22px;font-family: '行书';border-radius: 5px;}</style>--><style>.shapeClass{width: 60px;height: 40px;}.colorclass{background-color: aquamarine;color: black;border: 1px solid green;}.fontClass{font-size: 22px;font-family: '行书';border-radius: 5px;}</style></head>
<body><input id="六花" class="colorclass shapeClass fontClass" type="button" value="按钮"><input  type="button" value="按钮"><input id="二奶" type="button" value="按钮"></body>
</html>

浮动

float: 加上方位

如:float: right;

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>.outerdiv{background-color:burlywood ;height: 500px;width: 600px; }.innerdiv{height:60px ;width: 100px;border: 1px solid black;}.d1{background-color: green;float: right;}.d2{background-color: red;float: right;}.d3{background-color: yellow;float: right;}</style></head>
<body><div class="outerdiv" ><div class="innerdiv d1">diva</div><div class="innerdiv d2">divx</div><div class="innerdiv d3">divy</div></div></body>
</html>

定位

 position

                    static 默认(不行动)

                    absolute  绝对  其他的会填充

                    relative  相对原来的位置  其他的不会填充

                    fixed   相对浏览器的窗口 其他的会填充

            top

            right

            left

            bottom

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>.outerdiv{background-color:burlywood ;height: 500px;width: 600px; }.innerdiv{height:60px ;width: 100px;border: 1px solid black;}.d1{background-color: green;position: static;top: 60px;left: 60px;}.d2{background-color: red;}.d3{background-color: yellow;}</style></head>
<body><div class="outerdiv" ><div class="innerdiv d1">diva</div><div class="innerdiv d2">divx</div><div class="innerdiv d3">divy</div></div></body>
</html>

  盒子模型

内边距 padding

外边距 margin

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>.outerdiv{background-color:burlywood ;height: 500px;width: 600px; margin: 0px auto;}.innerdiv{height:60px ;width: 100px;border: 1px solid black;float: left;}.d1{background-color: green;margin-right: 10px;padding-top: 20px;}.d2{background-color: red;margin-left: 10px;}.d3{background-color: yellow;}</style></head>
<body><div class="outerdiv" ><div class="innerdiv d1">diva</div><div class="innerdiv d2">divx</div><div class="innerdiv d3">divy</div></div></body>
</html>

http://www.lryc.cn/news/524645.html

相关文章:

  • 实施工程师:面试基础宝典
  • react install
  • ElasticSearch DSL查询之排序和分页
  • uniapp封装websocket
  • 【Linux】18.Linux进程控制(2)
  • reactor框架使用时,数据流请求流程
  • 读西瓜书的数学准备
  • 摄像头模块如何应用在宠物产品领域
  • c++学习第七天
  • Ubuntu 24.04 LTS 通过 docker 安装 nextcloud 搭建个人网盘
  • RabbitMQ1-消息队列
  • Open3D计算点云粗糙度(方法一)【2025最新版】
  • 算法6(力扣148)-排序链表
  • 一文大白话讲清楚webpack基本使用——9——预加载之prefetch和preload以及webpackChunkName的使用
  • 【大数据2025】MapReduce
  • Windows图形界面(GUI)-QT-C/C++ - Qt List Widget详解与应用
  • 深度学习python基础(第二节) 分支语句和循环语句
  • Gin 源码概览 - 路由
  • 第6章 ThreadGroup详细讲解(Java高并发编程详解:多线程与系统设计)
  • CentOS 7乱码问题如何解决?
  • JavaScript语言的多线程编程
  • OpenSeaOtter使用手册-变更通知和持续部署
  • (2)STM32 USB设备开发-USB虚拟串口
  • 他把智能科技引入现代农业领域
  • ingress-nginx代理tcp使其能外部访问mysql
  • 麒麟操作系统服务架构保姆级教程(十三)tomcat环境安装以及LNMT架构
  • 亚博microros小车-原生ubuntu支持系列:4-手部检测
  • 关于回调函数(callback)
  • Linux Bash 中使用重定向运算符的 5 种方法
  • 硬件作品3----STM32F103RCT6最小系统板MCU配置