Home  >  Article  >  Web Front-end  >  Things about position in css style layout_html/css_WEB-ITnose

Things about position in css style layout_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:56:291080browse

Hey, page layout and design development are indeed very time-consuming, laborious, and difficult for someone who has been engaged in backend development.


Tonight I want to overlap multiple pictures together, or mark different locations in a picture and assign hyperlinks. It took me a whole night to get it initially, and I roughly understood the usage of the following css attributes.


【1】Set the tag to float and discuss with your colleagues:

HTML tags have block level and line level (as for those that are block level, According to Baidu), each block level will occupy one line of the html document (the reason why it is one line is that there will be a line break after the block level). If the block-level label is set to float, the label: (1) is separated from the original parent label. (2) Can be displayed on one line.


【2】position is set to fixed.

fixed is relative to the entire browser. Interested students can try it out by setting a sized label to fixed and zooming the browser so that the browser generates scroll bars (up and down or left and right). When the scroll bar is pulled, the label set to fixed will not change. of its location.


【3】position is set to absolute.

absolute is relative to the nearest parent tag. Still the same experiment as above, when the scroll bar is pulled, the label set to absolute will also change with the change of the position of the html document.


【4】position is set to relative.

relative is relative to the original position of the tag.


The following is a test picture I made tonight to see the effect:


(1) line a It is absolute

(2) Line b is fixed.

My main purpose in the above picture is to mark the positions of make1~8 in the disk, and then provide hyperlinks. The specific code is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><!--<link type="text/css" rel="stylesheet" media="all" href="webCss.css">--><title>mydw</title><style>body {	background:#CCCCCC;}a.makeR1{ left:150px; top:45px; width:70px; height:80px;}a.makeR2{ right:150px; top:45px;width:70px; height:80px;}a.makeR3{ left:65px; top:135px; width:70px; height:80px;}a.makeR4{ right:65px; top:135px;width:70px; height:80px;}a.makeR5{ left:65px; top:265px; width:70px; height:80px;}a.makeR6{ right:65px; top:265px;width:70px; height:80px;}a.makeR7{ right:215px; top:365px;width:70px; height:60px;}a.makeR8{ right:180px; top:160px;width:137px; height:137px;}.makeR9{ right:180px; top:160px;width:137px; height:137px;}.roundMakeBox{	position:fixed;	z-index:99992; 		text-align:center;	left:50%; 	margin-left:-250px; 	width:499px;	height:501px;	border:1px solid blue;}.roundLink{ position:relative; bottom:0px;z-index:99993;border:1px solid green;}.roundLink a{ display:block;position:absolute;z-index:99994;border:1px solid red;background:#FFFF00;}#img1{ display:block;position:absolute;z-index:99994;border:1px solid red;}</style></head><body><div class="roundMakeBox">	<div class="roundLink">		<img src="makeRound.png">		<a href="#" class="makeR1">makeR1</a>		<a href="#" class="makeR2">makeR2</a>		<a href="#" class="makeR3">makeR3</a>		<a href="#" class="makeR4">makeR4</a>		<a href="#" class="makeR5">makeR5</a>		<a href="#" class="makeR6">makeR6</a>		<a href="#" class="makeR7">makeR7</a>		<a href="#" class="makeR8">makeR8</a>		<img id="img1" class="makeR9" src="LOGObg.png" />	</div></div></div></body></html>


In addition

【1】 Regarding the issue of roundMakeBox centering:

left:50%; margin-left:-250px; 
left:50% is the movement of the left edge of the label to 50% (half) of the parent tag, so why do we need margin-left -250px?

Because when I left50%, although the left edge of the label has reached 50%, the entire label is indeed offset to the right. What we call label centering means that the center position of the label is at the center of the parent label. Left50% obviously moves the normal position of the label more. The original label is 500px, so the margin-left-250px is used.


【2】How do you get the pixel position of each a in makeR?

After figuring out the absolute value of position, the only thing left is to measure the position (what to measure? I use a ruler, I don’t know if there is any other better way).


Okay, the above is my understanding. I don’t know if it is expressed clearly or my understanding is biased. The reader needs to experiment by himself. test.


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