Home  >  Article  >  Web Front-end  >  div css to make rounded rectangle [updated version]_html/css_WEB-ITnose

div css to make rounded rectangle [updated version]_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:31:07999browse

Today I looked at the div+css implementation of Think’s rounded rectangle. This is roughly what he did.

It accumulates or decreases bit by bit according to the margin. The results are relatively good! Just practice and study~

 html part

<!-- round main -->	<div id="round">    	                <!-- r_top --->                <div class="r_top">                        <em class="r_a"></em>                        <em class="r_b"></em>                        <em class="r_c"></em>                        <em class="r_d"></em>                </div>                 <!-- //r_top  end --->                                     <!-- r_box --->                <div class="r_box">                    这是一个圆角矩形!<br />                    这是一个圆角矩形!<br />                    这是一个圆角矩形!<br />                    这是一个圆角矩形!<br />                    这是一个圆角矩形!<br />                    这是一个圆角矩形!<br />                </div>                 <!-- //r_box  end --->                                    <!-- r_bottom --->                <div class="r_bottom">                         <em class="r_d"></em>                        <em class="r_c"></em>                        <em class="r_b"></em>                        <em class="r_a"></em>                               </div>                   <!-- //r_bottom  end--->                          </div>    <!-- // round main end-->

css part

	div,em{ margin:0; padding:0;}	#round{ width:500px; margin:0px 20px; }	.r_top,.r_bottom{ display:block; font-size:1px;}		.r_a,.r_b,.r_c,.r_d{ display:block; overflow:hidden; }	.r_a,.r_b,.r_c{ height:1px;}	.r_b,.r_c,.r_d{background:#CCFF66; }			.r_box{ background:#CCFF66; padding-left:10px; padding-right:10px;}		.r_a{ margin:0 5px; }	.r_b{ margin:0 3px; border-width:0 2px; }	.r_c{ margin:0 2px; }	.r_d{ height:2px; margin:0 1px; }

Test compatibility. It's ok for now. I haven't found any major problems yet~~.

为了更好的理解,先用简单的代码为例。XHTML代码:<b class="top"><b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b></b>CSS代码:b{display:block;}.b1,.b2,.b3,.b4{overflow:hidden;height:1px;border-left:1px solid #000;border-right:1px solid #000;}.b1{margin:0 5px;background:#000;}.b2{margin:0 3px;border-width:0 2px;}.b3{margin:0 2px;}.b4{height:2px;margin:0 1px;}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn