Web基础与布局

目录

任务一:使用富文本编辑器

拓展:CSS盒子模型

自测

参考资料


任务一:使用富文本编辑器

<style>
    /*
    table 中的 class 为编辑器自动添加,使用的是它内置的样式
    这里主要讲表格隔行换色
    */

    /*奇数行*/
    table tr:nth-child(odd) {
        background-color: gray;
    }
    /*偶数行*/
    table tr:nth-child(even) {
        background-color: red;
    }
</style>

<p>Hello world!</p>

<table class="table table-bordered">
    <tbody>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
    </tbody>
</table>

<input type="button" onclick="alert('确定')" value="确定">
<button id="btn" onclick="alert('确定')">OK</button>

编写好表格代码后,在css代码中,使用 nth-child 方法区别表格中每一行的奇偶数(奇数行:odd,偶数行:even),给奇数和偶数列分别赋予不同的颜色

在按钮的 onclick 属性中添加需要执行的操作,点击按钮即可做出响应。

最终实现效果如下:

拓展:CSS盒子模型

  • 完成下图的CSS盒子模型布局

HTML代码:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>demo</title>
    <link rel="stylesheet" href="new 1.css">
	</head>
	<body>
		<div id = "main">
			<div class = "big-box1">
				<div class = "box1 color-green"> 1 </div>
				<div class = "box2 color-green"> 2 </div>
			</div>
			<div class = "big-box2">
				<div class = "box3 color-green"> 3 </div>
				<div class = "box7 color-orange"> 7 </div>
				<div class = "box8 color-orange"> 8 </div>
			</div>
			<div class = "big-box3">
				<div class = "box49">
					<div class = "box4 color-green"> 4 </div>
					<div class = "box9 color-orange"> 9 </div>
				</div>
				<div class = "box56">
					<div class = "box5 color-green"> 5 </div>
					<div class = "box6 color-green"> 6 </div>
				</div>
			</div>
		</div>
	</body>
</html>

CSS代码:

* {
	margin: 0;
	padding: 0;
}

#main {
	width: 900px;
	height: 600px;
    color: #FFF;
	font-size: 28px;
	background-color: rgb(252, 221, 156);
	border: solid 5px rgb(170, 170, 170);
	margin:200px auto;
	position:relative;
}

	#main div {
		text-align: center;
	}

.color-orange {
	background-color: rgb(243, 164, 100);
	/*border: solid 1px rgb(170, 170, 170);*/
}
.color-green {
	background-color: rgb(197, 208, 142);
	/*border: solid 2px rgb(170, 170, 170);*/
}

.big-box1 {
	width: 260px;
	height: 580px;
	padding: 10px;
	float: left;
}

	.box1 {
		width: 260px;
		height: 130px;
		line-height: 130px;
	}
	.box2 {
		width: 260px;
		height: 430px;
		line-height: 420px;
		margin-top: 20px;
	}

.big-box2 {
	width: 600px;
	height: 220px;
	padding: 10px;
	float: right;
	position: relative;
}
	
	.box3 {
		position: absolute;
		width: 600px;
		height: 220px;
		line-height: 220px;
	}
	.box7 {
		width: 180px;
		height: 140px;
		line-height: 140px;
		position: absolute;
		left: 30px;
		top: 50px;
	}
	.box8 {
		width: 180px;
		height: 140px;
		line-height: 140px;
		position: absolute;
		right: 30px;
		top: -100px;
	}
	
.big-box3 {
	width: 600px;
	height: 340px;
	padding: 10px;
	float: right;
}

	.box49 {
		width: 290px;
		height: 340px;
		float: left;
		position: relative;
	}
	
		.box4 {
			width: 290px;
			height: 340px;
			line-height: 340px;
			position: relative;
			z-index: 2;	/*z-index的值越大,越在最上层。*/
		}
		
		.box9 {
			width: 180px;
			height: 160px;
			line-height: 140px;
			position: absolute;
			left: 30px;
			bottom: -120px;
			z-index: 1;
		}
	
	.box56 {
		width: 290px;
		height: 340px;
		float: right;
	}
	
		.box5 {
			width: 290px;
			height: 160px;
			line-height: 160px;
		}
		.box6 {
			width: 290px;
			height: 160px;
			line-height: 160px;
			margin-top: 20px;
		}

完成效果如下

自测

在 img 标签内加入 draggable 属性,并将其设为 true ;

不过这仅仅是将它设置为可拖放,真正要实现拖放这样好像还不够,等研究好之后再更新。

HTML5 拥有多个可供选取日期和时间的新输入类型:

  1. date:选取日、月、年
  2. month:选取月、年
  3. week:选取周和年
  4. time:选取时间(小时和分钟)
  5. datetime-local:选取时间、日、月、年(本地时间)
  6. datetime:选取时间、日、月、年(在有些浏览器内失效,选用datetime-local)

例:

※ datatime调不出日历控件是因为有些浏览器不支持datetime这种日历控件 ※

※ Internet Explorer、Firefox 和 Chrome 不支持 datetime 类型的 input;Safari 中部分支持;Opera 12 以及更早的版本中完全支持 ※​​​​

Margin:外边距

Border:边框

Padding:内边距

  1. onfocus:当元素获得焦点时触发
  2. onblur:当元素失去焦点时触发
  3. onload:当文档加载时触发
  4. onkeydown:当按下按键时触发
  5. onclick:当单击鼠标时触发
  6. ondblclick:当双击鼠标时触发
  • HTML 的 onblur 和 onfocus 是哪种类型的属性?

都是 HTML 的事件属性。

onblur:当元素失去焦点时触发

onfocus:当元素获得焦点时触发

  • 怎么设置 display 属性的值使容器成为弹性容器?

将 display 属性设为 flex

  • JavaScript 中有多少中不同类型的循环?

看到有大佬说有15种,但是我只知道这三种:for 循环、do...while 循环和 while 循环。(菜鸡本鸡)

语义化标签可以使用 

参考资料

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

butucode

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值