css使用

图片在div内垂直居中

<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>RunJS</title>
		<style>
			div{
				line-height: 300px;
				border:1px solid red
			}
			img{
					vertical-align: middle;
				}
		</style>
	</head>
	<body>
		<div id="div1">
				<img src="http://lorempixel.com/400/200/">
		</div>
	</body>
</html>

省略号(block,inline)

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div,p{
             100px;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
            background: red;
        }
        span{
            display: block;/* 先转化成block */
             100px;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
            background: green;
        }
    </style>
</head>
<body>
    <div>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</div>
    <p>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</p>
    <span>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</span>
</body>
</html>

原文地址:https://www.cnblogs.com/leee/p/7346431.html