CSS实例【十二】

最后一波CSS基础内容 来了~

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
		/* home和next用了同一个图的不同位置 */
			img.home{
				width:46px;
				height: 44px;
				background:url(image/sun.gif) 0 0;
			}
			img.next{
				width: 43px;
				height: 44px;
				background: url(image/sun.gif) -91px 0;
			}
			#navlist{position: relative;}
			#navlist li{
				margin:0;
				padding: 0;
				list-style: none;
				position: absolute;
				top: 10;
			}
			#navlist li,#navlist a{
				height: 44px;
				display: block;
			}
			#prev{
				left:50px;
				width: 90px;
			}
			#prev{
				/* 进链接的图片 */
				background: url('image/img_navsprites.png') -99px -30px;
			}
			#prev a:hover{
				background: url('image/img_navsprites2.png')-97px -110px;
				/* 往右为负多少,第二个往下为负多少 */
			}
			[title]
			{
				color: blue;
			}
			[title=runoob]
			{
				border: 5px solid green;
			}
			[title~=hello]
			{
				color: #CA5BFB; 
			}
			[lang |=en]{
				color: #FBCD72;
			}
		</style>
	</head>
	<body>
	<!-- 	<div >
			<h1>一、CSS图像拼合</h1>
			<h2>1.图像拼合</h2>
			<p>定义了一个空的img.gif,因为src不能为空</p>
			<img class="home" src="img.gif" ><br><br>
			<img class="next" src="img.gif" />
			<h2>2.导航列表</h2>
			<ul id="navlist"> -->
				<!-- 点击图片会跳转到链接里 -->
				<!-- <li id="prev"><a href="https://www.baidu.com/"</a></li>
			</ul>
		</div> -->
		
		<div>
			<h1>二、CSS属性选择器</h1>
			<h2>1.选择具有title属性的元素:</h2>
			<p>相当于指定带有title标签的内容按照要求做合适的样式</p>
			<h3>Will apple to:</h3>
			<h4 title="Hello World">Hello World!</h4>
			<a title="baidu" href="https://www.baidu.com/">baidu.com</a>
			<h2>2.选择标题=一个特定值的元素</h2>
			<h4 title="runoob" href="//www.runoob.com/">runoob</h4>
			<hr >
			
			<h2>3.选择标题=一个特定值的元素(使用~分隔属性和值)</h2>
			<h3 title="hello wanzi">hello wanzi</h3>
			<p title="student hello">Hello CSS students!</p>
			<hr >
			
			
			<h2>4.选择标题=一个特定值的元素(使用|分隔属性和值)</h2>
			<p lang="en">Here!</p>
			<p lang="en-us">OK!</p>
			<p lang="en-gb">Ello!</p>
			<hr >
			
			<h3>Will not apply to:</h3>
			<p>Hello!</p>
			<p title="student">Hi CSS student!</p>
			<p lang="us">No!</p>
			<p lang="no">Don't!</p>
			
		</div>
		
		
	</body>
</html>

这是CSS基础内容的最后一部分,后面会继续更新js的应用实例和html5与CSS3的内容。
勉励:「有志者,事竟成」

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,下面是一个使用CSS样式设计的实例。这是一个图片墙网页,包含多个图片,鼠标悬停时图片会有放大和变暗的效果。 ```html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>图片墙</title> <style> body { margin: 0; padding: 0; background-color: #f1f1f1; } .container { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; padding: 20px; } .item { position: relative; margin: 10px; overflow: hidden; border-radius: 5px; box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3); transition: transform 0.5s ease; } .item:hover { transform: scale(1.2); } .item:hover img { opacity: 0.5; } .item img { display: block; width: 100%; height: 100%; transition: opacity 0.5s ease; } .item .title { position: absolute; bottom: 0; left: 0; right: 0; background-color: rgba(0, 0, 0, 0.5); color: #fff; padding: 10px; font-size: 20px; text-align: center; transition: bottom 0.5s ease; } .item:hover .title { bottom: -50px; } </style> </head> <body> <div class="container"> <div class="item"> <img src="https://picsum.photos/400/300" alt=""> <div class="title">图片1</div> </div> <div class="item"> <img src="https://picsum.photos/400/301" alt=""> <div class="title">图片2</div> </div> <div class="item"> <img src="https://picsum.photos/400/302" alt=""> <div class="title">图片3</div> </div> <div class="item"> <img src="https://picsum.photos/400/303" alt=""> <div class="title">图片4</div> </div> <div class="item"> <img src="https://picsum.photos/400/304" alt=""> <div class="title">图片5</div> </div> <div class="item"> <img src="https://picsum.photos/400/305" alt=""> <div class="title">图片6</div> </div> </div> </body> </html> ``` 上述代码,我们使用了CSS样式来设计一个图片墙网页。首先,我们使用`<div>`标签来创建一个容器,使用`display: flex`来设置容器为弹性布局,使用`flex-wrap: wrap`来设置容器内部元素自动换行。然后,我们使用`<div>`标签来创建多个图片项,使用`position: relative`来设置图片项为相对定位,使用`overflow: hidden`来设置图片溢出部分隐藏,使用`border-radius: 5px`来设置图片项圆角,使用`box-shadow`来设置图片项阴影效果。 在鼠标悬停时,我们使用CSS的`hover`伪类来设置图片和标题的效果。使用`transform: scale(1.2)`来设置图片放大效果,使用`opacity: 0.5`来设置图片变暗效果,使用`transition`来设置过渡效果。使用`bottom: -50px`来设置标题向上移动50像素的效果。 上述代码只是一个简单的图片墙网页示例,你可以根据自己的需要进行修改和扩展。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值