本系列博客汇总在这里:JavaWeb_CSS 汇总
一、div 的边框样式
- 示例
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> www.weiyuxuan.com </title> <style type="text/css"> div { font-family: 楷体; font-size: 20px; font-weight:bold; background-color: orange; width: 100px; height: 100px; text-align: center; border-width: 6px; } </style> </head> <h1> 边框 </h1> <hr> <body> <div style="border-style: double;"><img src="test.jpg"/></div> <div style="border-style: double;"><img src="test.jpg"/></div> <div><img src="test.jpg"/></div> </body> </html>
- 示例
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> www.weiyuxuan.com </title> <style type="text/css"> .outside { padding: 10px 10px 10px 10px; /*从上边距顺时针赋予宽度*/ border: 1px solid black; /*给边框设置宽度,样式,颜色 , 多个样式的值用空格分开*/ width: 800px; background-color: yellow; } .inside { width: 100%; height: 100%; background-color: orange; border: 1px solid black; } </style> </head> <h1> 内边框 </h1> <hr> <body> <div class="outside"> <div class="inside">内容</div> </div> </body> </html>
- 示例一
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> www.weiyuxuan.com </title> <style type="text/css"> span { font-size: 12px; font-family: Arail; padding: 10px; background-color: orange; border: 1px solid black; } .right { background-color: orange; margin-right: 10px; } .left { background-color: orange; margin-left: 10px; } </style> </head> <h1> 外边框 </h1> <hr> <body> <span class="right">元素1</span> <span class="left">元素2</span> </body> </html>
- 示例二
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> www.weiyuxuan.com </title> <style type="text/css"> div { font-size: 12px; font-family: Arial; padding: 10px; background-color: yellow; border: 1px solid black; } .inside { background-color: orange; margin: 10px 30px 10px 30px; } </style> </head> <h1> 外边框 </h1> <hr> <body> <div class="outside"> <div class="inside">内部 div </div> </div> </body> </html>
如有错误,欢迎指正!