首页 > 其他分享 >CSS盒子

CSS盒子

时间:2024-10-07 13:11:50浏览次数:1  
标签:style 盒子 electric color height width border CSS

1.width,height宽度高度。
<!DOCTYPE html>
<html>
	<head>
		<title>Width Height</title>
		<style type="text/css">
			body {
				font-family: Arial, Verdana, sans-serif;
				color: #111111;}
			div {
				width: 400px;
				height: 300px;
				background-color: #ee3e80;}
			p {
				height: 75%;
				width: 75%;
				background-color: #e1ddda;}
		</style>
	</head>
	<body>
		<div>
			<p>The Moog company pioneered the commercial manufacture of modular voltage-controlled analog synthesizer systems in the early 1950s.</p>
		</div>
	</body>
</html>
使用百分数时,盒子的大小与浏览器窗口的大小有关。如果是盒子套盒子,百分数就是相当于外部盒子而言。比如P就是300*75%=225
em值盒子大小以盒子中的文本为基准
2.宽度限制min-width,max-width
保证在不同的设备上显示的效果不会太窄,宽。
<html>
	<head>
		<title>Min Width Max Width</title>
		<style type="text/css">
			body {
				font-family: Arial, Verdana, sans-serif;
				color: #111111;}
			th {
				border-bottom: 1px solid #0088dd; 
				text-align: left; 
				color: #0088dd;
				font-weight: normal;}
			td {
				min-width: 150px;
				min-height: 200px;
				vertical-align: top;
				line-height: 1.4em;}
			td.description {
				min-width: 450px;
				max-width: 650px;
				text-align: left;
				padding: 5px;
				margin: 0px;}
			</style>
	</head>
	<body>
		<table>
			<tr>
				<th>Photo</th>
				<th>Description</th>
				<th>Price</th>
			</tr>
			<tr>
				<td><img src="images/rhodes.jpg" width="200" height="150" alt="Fender Rhodes" /></td>
				<td class="description">The Rhodes piano is an electro-mechanical piano, invented by Harold Rhodes during the fifties and later manufactured in a number of models, first in collaboration with Fender and after 1965 by CBS. It employs a piano-like keyboard with hammers that hit small metal tines, amplified by electromagnetic pickups.</td>
				<td>$1400</td>
			</tr>
			<tr>
				<td><img src="images/wurlitzer.jpg" width="200" height="150" alt="Wurlitzer EP200" /></td>
				<td class="description">The Wurlitzer electric piano is an electro-mechanical piano, created by the Rudolph Wurlitzer Company of Mississippi. The Wurlitzer company itself never called the instrument an "electric piano", instead inventing the phrase "Electronic Piano" and using this as a trademark throughout the production of the instrument. It employs a piano-like keyboard with hammers that hit small metal tines, amplified by electromagnetic pickups.</td>
				<td>$1600</td>
			</tr>
			<tr>
				<td><img src="images/clavinet.jpg" width="200" height="150" alt="Hohner Clavinet D6" /></td>
				<td class="description">A Clavinet is an electronically amplified clavichord manufactured by the Hohner company. Each key uses a rubber tip to perform a hammer on a string. Its distinctive bright staccato sound is often compared to that of an electric guitar. Various models were produced over the years, including the models I, II, L, C, D6, and E7.</td>
				<td>$1200</td>
			</tr>
		</table>
	</body>
</html>
3.高度限制 min-height,max-height
<!DOCTYPE html>
<html>
	<head>
		<title>Min Height Max Height</title>
		<style type="text/css">
			body {
				font-family: Arial, Verdana, sans-serif;
				color: #111111;}
			h2, p {
				width: 400px;
				font-size: 90%;
				line-height: 1.2em;}
			h2 {
				color: #0088dd;
				border-bottom: 1px solid #0088dd;}
			p {
				min-height: 10px;
				max-height: 30px;}
		</style>
	</head>
	<body>
		<h2>Fender Mustang</h2>
		<p>The Fender Mustang was introduced in 1964 as the basis of a major redesign of Fender's student models then consisting of the Musicmaster and Duo-Sonic. It was originally popular in sixties surf music and attained cult status in the 1990s largely as a result of its use by a number of alternative rock bands.</p>
		<h2>Fender Stratocaster</h2>
		<p>The Fender Stratocaster or "Strat" is one of the most popular electric guitars of all time, and its design has been copied by many guitar makers. It was designed by Leo Fender, George Fullerton and Fredie Tavares in 1954.</p>
		<h2>Gibson Les Paul</h2>
		<p>The Gibson Les Paul is a solid body electric guitar that was first sold in 1952. The Les Paul was designed by Ted McCarty in collaboration with popular guitarist Les Paul, whom Gibson enlisted to endorse the new model. It is one of the most well-known electric guitar types in the world.</p>
	</body>
</html>
4.内容溢出overflow
告诉浏览器当盒子的内容超过盒子本身时如何显示,它有像个属性值可供选择。
hidden溢出部分隐藏
scroll添加滚动条
<!DOCTYPE html>
<html>
	<head>
		<title>Overflow</title>
		<style type="text/css">
			body {
				font-family: Arial, Verdana, sans-serif;
				color: #111111;
				font-size: 90%;
				line-height: 1.2em;
				width: 200px;}
			h2 {
				color: #0088dd;
				border-bottom: 1px solid #0088dd;}
			p {
				min-height: 30px;
				max-height: 85px;}
			p.one {
				overflow: hidden;}
			p.two {
				overflow: scroll;}
		</style>
	</head>
	<body>
		<h2>Fender Stratocaster</h2>
		<p class="one">The Fender Stratocaster or "Strat" is one of the most popular electric guitars of all time, and its design has been copied by many guitar makers. It was designed by Leo Fender, George Fullerton and Fredie Tavares in 1954.</p>
		<h2>Gibson Les Paul</h2>
		<p class="two">The Gibson Les Paul is a solid body electric guitar that was first sold in 1952. The Les Paul was designed by Ted McCarty in collaboration with popular guitarist Les Paul, whom Gibson enlisted to endorse the new model. It is one of the most well-known electric guitar types in the world.</p>
	</body>
</html>
5.边框,外边距和内边距
(1)每个盒子都有边框,边框将一个盒子的边缘和另一个盒子隔开。
(2)外边距位于边框的边缘之外。你可以通过设置外边距的宽度在两个相邻盒子的边缘之间创建空隙
(3)内边距是指盒子边框与盒子所包含内容之间的空隙。增加内边距可以提高内容的可读性。
5.边框宽度border-width
该属性可以是像素值也可以是以下值之一thin,medium,thick。不能是百分数
也可以通过border-top-width,border-right-width,border-bottom-width,border-left-width控制
border-width:2px 1px 1px 2px;顺时针上右下左
<!DOCTYPE html>
<html>
	<head>
		<title>Border Width</title>
		<style type="text/css">
			body {
				font-family: Arial, Verdana, sans-serif;
				color: #111111;}
			p {
				width: 200px;
				border-style: solid;}
			p.one {
				border-width: 2px;}
			p.two {
				border-width: thick;}
			p.three {
				border-width: 1px 4px 12px 4px;}
		</style>
	</head>
	<body>
		<p class="one">Hohner's "Clavinet" is essentially an electric clavichord.</p>
		<p class="two">Hohner's "Clavinet" is essentially an electric clavichord.</p>
		<p class="three">Hohner's "Clavinet" is essentially an electric clavichord.</p>
	</body>
</html>
6.边框样式border-style
solid,实线。dotted方形点,dashed 虚线。double 双实线 groove雕入页面效果。ridge,凸起。inset嵌入,outset凸出屏幕。hidden/none不显示
同样可以用border-top-style,border-right-style,border-bottom-style,border-left-style;
<!DOCTYPE html>
<html>
	<head>
		<title>Border Style</title>
		<style type="text/css">
			body {
				font-family: Arial, Verdana, sans-serif;
				color: #111111;}
			p {
				width: 250px;
				border-width: 3px;}
			p.one {
				border-style: solid;}
			p.two {
				border-style: dotted;}
			p.three {
				border-style: dashed;}
			p.four {
				border-style: double;}
			p.five {
				border-style: groove;}
			p.six {
				border-style: ridge;}
			p.seven {
				border-style: inset;}
			p.eight {
				border-style: outset;}
		</style>
	</head>
	<body>
		<p class="one">Wurlitzer Electric Piano</p>
		<p class="two">Wurlitzer Electric Piano</p>
		<p class="three">Wurlitzer Electric Piano</p>
		<p class="four">Wurlitzer Electric Piano</p>
		<p class="five">Wurlitzer Electric Piano</p>
		<p class="six">Wurlitzer Electric Piano</p>
		<p class="seven">Wurlitzer Electric Piano</p>
		<p class="eight">Wurlitzer Electric Piano</p>
	</body>
</html>
7.边框颜色。rgb,十六进制,颜色名
border-top-color,border-right-color,border-bottom-color,border-left-color。
<!DOCTYPE html>
<html>
	<head>
		<title>Border Color</title>
		<style type="text/css">
			body {
				font-family: Arial, Verdana, sans-serif;
				color: #111111;}
			p {
				border-style: solid; 
				border-width: 3px;
				width: 200px;}
			p.one {
				border-color: #0088dd;}
			p.two {
				border-color: #bbbbaa #111111 #ee3e80 #0088dd;}
		</style>
	</head>
	<body>
		<p class="one">The ARP Odyssey was introduced in 1972.</p>
		<p class="two">The ARP Odyssey was introduced in 1972.</p>
	</body>
</html>
8.快捷方式写在一起
body {
				font-family: Arial, Verdana, sans-serif;
				color: #111111;}
			p {
				width: 250px;
				border: 3px dotted #0088dd;}

标签:style,盒子,electric,color,height,width,border,CSS
From: https://www.cnblogs.com/zhongta/p/18449926

相关文章

  • css选择器用法
    1.元素选择器(标签选择器)元素名称{} 2类选择器以点开头{}3.id选择器器以#号开头4.后代选择器空格分隔5.子类选择器>大于号分隔6.相邻兄弟选择器+连接选择与指定元素在同一层级且紧接在它后面的元素(只有一个)。h2+......
  • css核心
    1.属性值的计算过程是指任何一个html元素,它从所有的css属性都没有值,到所有的css属性都有值,它需要一个计算过程,这个就是属性值的计算过程2.视觉格式化模型是指页面中多个盒子的排列规则,俗称布局规则1》普通流包含块:大多数情况下,包含块就是父元素的内容盒,......
  • [CSS 3] Avatar hover effect
    <!doctypehtml><htmllang="en"><head><metacharset="utf-8"/><title>CSSavatarscale</title><style>.avatar{width:150px;height:150px;......
  • css字体
    1.字体分类SERIF:衬线字体。在字母的主要笔画末端有额外装饰。适合长篇文本SANS_SERIF无衬线字体。文本小的时候运用MONOSPACE等宽字体。每个字母宽度相同。用于显示代码CURSIVE:草书字体FANTASY虚幻字体,用于标题。不适合长篇文本2.字体选用font-family<styletype="text/c......
  • CSS元素可见性
    CSS中的visibility属性用来设置元素是否可见,您可以将该属性与JavaScript一起使用,来创建非常复杂的菜单或网页布局,比如在网页中做一些测试题时您可以使用visibility属性将题目的答案或解析隐藏起来,需要时再将其展示出来。visibility属性的可选值如下:值描述visible......
  • 22.响应式网络推广建站公司网页 Web前端网页制作 大学生期末大作业 html+css+js
     目录 一、前言 二、网页文件 三、网页效果四、代码展示1.HTML2.CSS3.JS 五、更多推荐一、前言 本实例应用html+css+js,响应式布局,可以根据不同的设备屏幕大小自动调整页面布局,手机等移动设备自适应界面,提高用户体验;支持包括IE、Firefox、Chrome、Safari等主......
  • CSS display: flex布局
    CSSdisplay:flex布局来源https://zhuanlan.zhihu.com/p/646436119前言早期CSS布局依赖display属性+position属性+float属性。它对特殊的布局非常不方便,如,垂直居中。于是,W3C在2009年提出了一种新的方案——Flex方案,可以简便、完整、响应式地实现各种页面布局。目前,它已......
  • CSS display属性 inline-block flex grid
    CSSdisplayinline-block flexgrid=======================================CSS的display属性是一个核心属性,用于控制元素如何在页面布局中显示,包括其盒模型的行为。以下是display属性的一些常见值及其示例代码:1.block   说明:将元素变为块级元素,独占一行,可以设置宽高、......
  • CSS3--美若天仙!?
    免责声明:本文仅做分享~ 目录CSS引入方式 选择器盒子尺寸和背景色文字控制属性单行文字垂直居中字体族font复合属性文本对齐方式文本修饰线color文字颜色-----复合选择器伪类选择器超链接伪类CSS特性继承性层叠性优先级Emmet写法背景属性背景图......
  • css颜色
    1.前景色<styletype="text/css"> body{ padding:20px; font-family:Arial,Verdana,sans-serif;} /*colorname*/ h1{ color:DarkCyan;} /*hexcode*/ h2{ color:#ee3e80;} /*rgbvalue*/ p{ color......