经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » HTMLCSS » CSS » 查看文章
【HTML&CSS】搜狐页面代码编写
来源:cnblogs  作者:时孚  时间:2018/10/29 9:37:09  对本文有异议
  1. <!DOCTYPE html>
  2. <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
  3. <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
  4. <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
  5. <!--[if gt IE 8]><!-->
  6. <html class="no-js">
  7. <!--<![endif]-->
  8.  
  9. <head>
  10. <meta charset="utf-8">
  11. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  12. <title>搜狐首页</title>
  13. <meta name="description" content="">
  14. <meta name="viewport" content="width=device-width, initial-scale=1">
  15. <link rel="Shortcut Icon" href="./META-INF/images/souhulogo.png" />
  16. <link rel="stylesheet" href="./sohu.css">
  17. </head>
  18.  
  19. <body>
  20. <div class="top">
  21. <div class="logo">
  22. <div class="logoimg">
  23. 图标
  24. </div>
  25. <div class="dapp">
  26. 下载app
  27. </div>
  28. </div>
  29. </div>
  30. <div class="mast">
  31. <!-- 第一部分 -->
  32. <div class="sousuo">
  33. <div class="sousuo1">
  34. 搜索1
  35. </div>
  36. <div class="sousuo2">
  37. 搜索2
  38. </div>
  39. </div>
  40. <!-- 第二部分 -->
  41. <div class="toutiaolianjie">
  42. 头条链接
  43. </div>
  44. <!-- 第三部分 -->
  45. <div class="guanggaolan">
  46. <div class="guanggaolan1">
  47. 广告1
  48. </div>
  49. <div class="guanggaolan2">
  50. 广告2
  51. </div>
  52. </div>
  53. <!-- 第四部分 -->
  54. <div class="xinwen">
  55. <!-- 第四部分第一列 图片新闻-->
  56. <div class="imgxinwen">
  57. <div class="bigimg">
  58. 大图新闻
  59. </div>
  60. <!-- 小图新闻 -->
  61. <div class="smallimg">
  62. <table class="smallimgtable">
  63. <tr>
  64. <td>
  65. <div class="smallimgall smallimg1">
  66. 小图标题新闻1
  67. </div>
  68. </td>
  69. <td>
  70. <div class="smallimgall smallimg2">
  71. 小图标题新闻2
  72. </div>
  73. </td>
  74. </tr>
  75. <tr>
  76. <td>
  77. <div class="smallimgall smallimg3">
  78. 小图标题新闻3
  79. </div>
  80. </td>
  81. <td>
  82. <div class="smallimgall smallimg4">
  83. 小图标题新闻4
  84. </div>
  85. </td>
  86. </tr>
  87. </table>
  88. </div>
  89. <!-- 视频标题栏 -->
  90. <div class="shipinbiaoti">
  91. 视频标题栏
  92. </div>
  93. <!-- 视频 -->
  94. <div class="shipin1">
  95. 大视频
  96. </div>
  97. <div class="leftnews1">
  98. 文字新闻
  99. </div>
  100. <div class="shipin2">
  101. 视频2
  102. </div>
  103. <div class="leftnews2">
  104. 文字新闻2
  105. </div>
  106. </div>
  107. <!-- 第四部分第二列 中间部分文字新闻-->
  108. <div class="textxinwen">
  109. <div class="textnewsall textnews1">
  110. 新闻标题8条
  111. </div>
  112. <div class="textnewsall textnews2">
  113. 新闻标题6条
  114. </div>
  115. <div class="textnewsall textnews3">
  116. 新闻标题6条
  117. </div>
  118. <div class="textnewsall textnews4">
  119. 新闻标题6条
  120. </div>
  121. <div class="textnewsall textnews5">
  122. 新闻标题6条
  123. </div>
  124. <div class="textnewsall textnews6">
  125. 新闻标题1条
  126. </div>
  127. </div>
  128. <!-- 第四部分第三列 右侧内容标题-->
  129. <div class="biaotilan">
  130.  
  131. <div class="right1">
  132. 换一换广告
  133. </div>
  134. <div class="right2">
  135. 图片广告
  136. </div>
  137. <div class="right3">
  138. 24小时热文
  139. </div>
  140. </div>
  141. </div>
  142. </div>
  143. <!-- 第五部分 -->
  144.  
  145. <script src="" async defer></script>
  146. </body>
  147.  
  148. </html>

 

看完一整本书,结果写不出什么东西,按书上教程来,基本能把例子完成个七七八八,可是用padding还是margin完全整不清……,而且只要结构一复杂,元素就各种不受控制。

没办法 找来韩顺平老师的视频(没错,就是在网上不知道怎么搞来的)

看完老师讲完整个html&CSS部分2,终于把这个内容吃透了。

韩顺平老师讲课最后一个用例就是还原搜狐门户网站的首页HTML和css部分,虽然视频中他的是n年前的网站页面,蛋根本不妨碍我完成完成现在版本的搜狐页面 。

 第一次看完视频,写的乱七八糟,很多东西摆不到应有的地方,没办法,在浏览器按f12键,查看人家的源代码,发现很多东西用了ul和li的组合插入文字,图片,而是原来HTML和css组合也没这么难,大神的代码实现也是很平凡很淡。

很多收获记手机上,回头整理发这里。

我做出来的效果图是这样的:

代码如下:

  1. <!DOCTYPE html>
  2. <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
  3. <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
  4. <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
  5. <!--[if gt IE 8]><!-->
  6. <html class="no-js">
  7. <!--<![endif]-->
  8.  
  9. <head>
  10. <meta charset="utf-8">
  11. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  12. <title>搜狐首页</title>
  13. <meta name="description" content="">
  14. <meta name="viewport" content="width=device-width, initial-scale=1">
  15. <link rel="Shortcut Icon" href="./META-INF/images/souhulogo.png" />
  16. <link rel="stylesheet" href="./sohu.css">
  17. </head>
  18.  
  19. <body>
  20. <div class="top">
  21. <div class="logo">
  22. <div class="logoimg">
  23. 图标
  24. </div>
  25. <div class="dapp">
  26. 下载app
  27. </div>
  28. </div>
  29. </div>
  30. <div class="mast">
  31. <!-- 第一部分 -->
  32. <div class="sousuo">
  33. <div class="sousuo1">
  34. 搜索1
  35. </div>
  36. <div class="sousuo2">
  37. 搜索2
  38. </div>
  39. </div>
  40. <!-- 第二部分 -->
  41. <div class="toutiaolianjie">
  42. 头条链接
  43. </div>
  44. <!-- 第三部分 -->
  45. <div class="guanggaolan">
  46. <div class="guanggaolan1">
  47. 广告1
  48. </div>
  49. <div class="guanggaolan2">
  50. 广告2
  51. </div>
  52. </div>
  53. <!-- 第四部分 -->
  54. <div class="xinwen">
  55. <!-- 第四部分第一列 图片新闻-->
  56. <div class="imgxinwen">
  57. <div class="bigimg">
  58. 大图新闻
  59. </div>
  60. <!-- 小图新闻 -->
  61. <div class="smallimg">
  62. <table class="smallimgtable">
  63. <tr>
  64. <td>
  65. <div class="smallimgall smallimg1">
  66. 小图标题新闻1
  67. </div>
  68. </td>
  69. <td>
  70. <div class="smallimgall smallimg2">
  71. 小图标题新闻2
  72. </div>
  73. </td>
  74. </tr>
  75. <tr>
  76. <td>
  77. <div class="smallimgall smallimg3">
  78. 小图标题新闻3
  79. </div>
  80. </td>
  81. <td>
  82. <div class="smallimgall smallimg4">
  83. 小图标题新闻4
  84. </div>
  85. </td>
  86. </tr>
  87. </table>
  88. </div>
  89. <!-- 视频标题栏 -->
  90. <div class="shipinbiaoti">
  91. 视频标题栏
  92. </div>
  93. <!-- 视频 -->
  94. <div class="shipin1">
  95. 大视频
  96. </div>
  97. <div class="leftnews1">
  98. 文字新闻
  99. </div>
  100. <div class="shipin2">
  101. 视频2
  102. </div>
  103. <div class="leftnews2">
  104. 文字新闻2
  105. </div>
  106. </div>
  107. <!-- 第四部分第二列 中间部分文字新闻-->
  108. <div class="textxinwen">
  109. <div class="textnewsall textnews1">
  110. 新闻标题8条
  111. </div>
  112. <div class="textnewsall textnews2">
  113. 新闻标题6条
  114. </div>
  115. <div class="textnewsall textnews3">
  116. 新闻标题6条
  117. </div>
  118. <div class="textnewsall textnews4">
  119. 新闻标题6条
  120. </div>
  121. <div class="textnewsall textnews5">
  122. 新闻标题6条
  123. </div>
  124. <div class="textnewsall textnews6">
  125. 新闻标题1条
  126. </div>
  127. </div>
  128. <!-- 第四部分第三列 右侧内容标题-->
  129. <div class="biaotilan">
  130.  
  131. <div class="right1">
  132. 换一换广告
  133. </div>
  134. <div class="right2">
  135. 图片广告
  136. </div>
  137. <div class="right3">
  138. 24小时热文
  139. </div>
  140. </div>
  141. </div>
  142. </div>
  143. <!-- 第五部分 -->
  144.  
  145. <script src="" async defer></script>
  146. </body>
  147.  
  148. </html>

css(html文件和css文件放同一个目录层下):

  1. body {
  2. margin: 0 auto;
  3. border: 1px solid red;
  4. }
  5. .mast {
  6. margin: 0 auto;
  7. width: 1180px;
  8. background-color: rgb(88, 88, 88);
  9. }
  10. .top {
  11. background-color: #222222;
  12. height: 30px;
  13. }
  14. .logo {
  15. width: 1180px;
  16. margin: 0 auto;
  17. background-color: yellow;
  18. }
  19.  
  20. /* 从这里开始一律采用左/右浮动 */
  21. .logoimg {
  22. float: left;
  23. width: 145px;
  24. height: 95px;
  25. background-color: #25c058;
  26. }
  27. .dapp {
  28. float: right;
  29. width: 160px;
  30. background-color: yellow;
  31. }
  32. .sousuo{
  33. float: right;
  34. width: 940px;
  35. height: 40px;
  36. background-color: #174b12;
  37. margin-top: 25px;
  38. }
  39. .sousuo1{
  40. float: left;
  41. width: 550px;
  42. height: 40px;
  43. background-color: rgb(0, 255, 98);
  44. }
  45. .sousuo2{
  46. float: right;
  47. width: 300px;
  48. height: 40px;
  49. background-color: rgb(10, 30, 92);
  50. }
  51. .toutiaolianjie{
  52. float: left;
  53. width: 1180px;
  54. height: 75px;
  55. background-color: #c9141d;
  56. margin-top: 26px;
  57. }
  58. .guanggaolan{
  59. float: left;
  60. width: 1180px;
  61. height: 100px;
  62. background-color: #DEE1EA;
  63. margin-top: 20px;
  64. }
  65. .guanggaolan1{
  66. float: left;
  67. width: 1030px;
  68. height: 100px;
  69. background-color: rgb(99, 75, 155);
  70. }
  71. .guanggaolan2{
  72. float: right;
  73. width: 144px;
  74. height: 100px;
  75. background-color: rgb(10, 30, 92);
  76. }
  77. .xinwen{
  78. float: left;
  79. width: 1180px;
  80. height: 1150px;
  81. background-color: rgb(71, 71, 71);
  82. margin-top: 20px;
  83. }
  84. .imgxinwen{
  85. float: left;
  86. width: 320px;
  87. height: 1120px;
  88. background-color: rgb(255, 123, 123);
  89. }
  90. .bigimg{
  91. float: left;
  92. width: 320px;
  93. height: 213px;
  94. background-color: rgb(251, 0, 0);
  95. }
  96. .smallimg{
  97. float: left;
  98. width: 320px;
  99. height: 320px;
  100. background-color: rgb(251, 0, 0);
  101. margin-top: 10px;
  102. }
  103. .smallimgtable{
  104. float: left;
  105. width: 320px;
  106. height: 320px;
  107. background-color: rgb(0, 153, 255);
  108. }
  109. .smallimgall{
  110. float: left;
  111. width: 155px;
  112. height: 155px;
  113. background-color: rgb(163, 163, 163);
  114. }
  115. .shipinbiaoti{
  116. float: left;
  117. width: 320px;
  118. height: 20px;
  119. background-color: rgb(163, 163, 163);
  120. margin-top: 30px;
  121. }
  122. .shipin1{
  123. float: left;
  124. width: 320px;
  125. height: 160px;
  126. background-color: rgb(123, 255, 0);
  127. margin-top: 12px;
  128. }
  129. .leftnews1{
  130. float: left;
  131. width: 320px;
  132. height: 70px;
  133. background-color: rgb(55, 0, 255);
  134. margin-top: 15px;
  135. }
  136. .shipin2{
  137. float: left;
  138. width: 320px;
  139. height: 104px;
  140. background-color: rgb(123, 255, 0);
  141. margin-top: 30px;
  142. }
  143. .leftnews2{
  144. float: left;
  145. width: 320px;
  146. height: 127px;
  147. background-color: rgb(230, 54, 186);
  148. margin-top: 15px;
  149. }
  150. .textxinwen{
  151. float: left;
  152. width: 440px;
  153. height: 1120px;
  154. background-color: rgb(30, 255, 49);
  155. margin-left: 25px;
  156. }
  157. .textnewsall{
  158. float: left;
  159. background-color: rgb(0, 202, 185);
  160. }
  161. .textnews1{
  162. float: left;
  163. width: 440px;
  164. height: 225px;
  165. background-color: rgb(0, 202, 185);
  166. }
  167. .textnews1,.textnews2,.textnews3,.textnews4,.textnews5{
  168. float: left;
  169. width: 440px;
  170. height: 180px;
  171. background-color: rgb(177, 106, 167);
  172. margin-top: 30px;
  173. }
  174. .textnews6{
  175. float: left;
  176. width: 440px;
  177. height: 20px;
  178. background-color: rgb(177, 106, 167);
  179. margin-top: 30px;
  180. }
  181. .biaotilan{
  182. float: right;
  183. width: 300px;
  184. height: 1120px;
  185. background-color: rgb(72, 52, 255);
  186. }
  187. .right1{
  188. float: left;
  189. width: 300px;
  190. height: 450px;
  191. background-color: rgb(217, 255, 0);
  192. }
  193. .right2{
  194. float: left;
  195. width: 300px;
  196. height: 250px;
  197. background-color: rgb(217, 255, 0);
  198. margin-top: 12px;
  199. }
  200. .right3{
  201. float: left;
  202. width: 300px;
  203. height: 414px;
  204. background-color: rgb(217, 255, 0);
  205. margin-top: 10px;
  206. }

 脑袋要炸了,继续完善!

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号