First look at the effect chart
Baidu News homepage solution:
The code is as follows: |
Copy code |
<Table> <Tbody> <Tr> <Td class = "topic-pic"> <a href = ""> </a> </td> <Td class = "topic-txt">... </Td> </Tr> </Tbody> </Table> |
The html structure is ugly, but css is simple.
Sina Weibo homepage solution:
The code is as follows: |
Copy code |
<Div class = "twit_item MIB_linedot2"> <Div class = "twit_item_pic"> <A href = "" target = "_ blank">
</A> </Div> <Div class = "twit_item_content"> .... </Div> </Div> |
CSS:
The code is as follows: |
Copy code |
. Twit_list dd. twit_item_pic {float: left; width: 66px; padding-top: 2px ;}. twit_list dd. twit_item_content {float: left; width: Pixel; color: #666; line-height: 18px ;} |
This is the answer for most candidates. When floating is used, the width must be fixed, the structure will lose flexibility, and a series of problems brought about by floating must be solved.
NetEase homepage solution:
The code is as follows: |
Copy code |
<Ul> <Li class = "list-figure"> <a href = ""> </a> </li> <Li> <a href = "">... </A> </li> <Li> <a href = "">... </A> </li> <Li> <a href = "">... </A> </li> </Ul> |
CSS:
The code is as follows: |
Copy code |
. List-figure {float: left; _ display: inline; width: 130px; margin-left:-140px; margin-top: 6px ;} |
These writing methods lack understanding of the basic concepts of css. If you understand the concept of block formatting context (block-level formatting context), it will not be written like this. The edge of the block-level element that triggers BFC does not overlap with the float box.
Recommended solution:
The code is as follows: |
Copy code |
<Div class = "item"> <Div class = "pic">... </div> <Div class = "content">... </div> </Div> |
CSS:
The code is as follows: |
Copy code |
. Item. pic {float: left; margin-right: 10px ;} . Item. content {overflow: hidden; zoom: 1;}/* or display: table-cell */ |
An instance I wrote
The code is as follows: |
Copy code |
<! DOCTYPE html> <Html lang = "zh"> <Head> <Meta charset = "utf-8"> <Meta http-equiv = "X-UA-Compatible" content = "IE = edge, chrome = 1"> <Meta name = "viewport" content = "width = device-width"> <Style type = "text/css"> Body { Margin: 0; Padding: 1em 0; Background-color: # f3f3f3; Font: 16px/1.7 Arial, Helvetica, sans-serif; Color: # 5a5a5a } A { Color: # 08c; Text-decoration: none } Header h1 { Text-align: center } Ul {margin: 0; padding: 0} Ul li {list-style: none; margin: 0; font-size: 13px ;} H3 {line-height: 1.7; margin: 0} . Item. pic {float: left; margin-right: 10px ;} . Item. content {overflow: hidden; zoom: 1;}/* or display: table-cell */ </Style> <! -- [If lt IE 9]> <Script src = "http://html5shiv.googlecode.com/svn/trunk/html5.js"> </script> <! [Endif] --> </Head> <Body> <Header> implementation of the content on the right of the left image <Div class = "item"> <Div class = "pic"> </Div> <Div class = "content"> <H3> <a href = ""> title </a> <Ul> <Li> <a href = ""> Content 1 </a> </li> <Li> <a href = ""> Content content 2 </a> </li> <Li> <a href = ""> Content 3 </a> </li> <Li> <a href = ""> Content 4 </a> </li> </Ul> </Div> </Div> </Body> </Html> |
Summary
It is not a technology, but more a skill.
Because there is no system front-end development course in the school, the basic concepts of html, css, and javascript are very weak. Most people learn to read books first, and then find that books and practices are far away from each other. If you encounter any problems, you can search for them online. However, most of them are "skillful. Or follow the school's "cool" learning, mixed with a variety of good, bad experience to accept the whole. For example, to display the right content of a left image, write html and css (see the following figure ). This is my pen question. It looks very simple. But no one has answered the best answer yet. If you go to the internet to see how the large websites in China are implemented, you can't blame them.