CSS Float - inherit 属性



描述

元素的 floated 状态可以从其父元素继承。这意味着,如果父元素是 floated,则子元素也将是 floated。

可能的值

  • inherit − 从其父元素继承 float 属性值。

适用于

所有 HTML 元素。

DOM 语法


float: inherit;

以下是显示此属性效果的示例 -


<html>
<head>
<style>
	 	.parent {
	 	 	 float: left;
	 	 	 border: 2px solid #f0610e;
	 	 	 padding: 5px;
	 	 	 height: 160px;
	 	 	 background-color: #86f00e;
	 	}
	 	.tutimg {
	 	 	 float: inherit;
	 	 	 border: 3px solid #f0610e;
	 	 	 margin-right: 10px;
	 	}
</style>
</head>
<body>
	 	<div class="parent">
	 	 	 <img class="tutimg" src="images/tutimg.png" width="150" height="150" />
	 	 	 There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in
	 	 	 some form, by injected humour, or randomised words which don't look even slightly believable. If you are
	 	 	 going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle
	 	 	 of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making
	 	 	 this the first true generator on the Internet.
	 	</div>
</body>
</html>