CSS example (5): simple column implementation

Source: Internet
Author: User

Today, I spent some time pondering how to implement frequently-used topics on the web page in a concise manner. This is what we call this topic. I don't know what others call it:

The following are my HTML and CSS files, which allow you to easily switch between styles. If anyone has a more concise approach, please leave a message.

  HTML file:HTML code

  1. <? XML version = "1.0" encoding = "UTF-8"?>
  2. <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <HTML xmlns = "http://www.w3.org/1999/xhtml">
  4. <Head>
  5. <Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
  6. <Title> insert title here </title>
  7. <Link href = "column.css" style = "text/CSS" rel = "stylesheet"/>
  8. <SCRIPT type = "text/JavaScript">
  9. VaR gindex = 1;
  10. Function doswitch (){
  11. VaR E = Document. getelementbyid ('info ');
  12. /* The variable below is E, and the code highlighting seems to have a bug. Please note. */
  13. Ee. classname = E. classname. Split ('') [0] + 's' + (gindex % 3 + 1 );
  14. Gindex ++;
  15. }
  16. </SCRIPT>
  17. </Head>
  18. <Body>
  19. <Ul class = "column S1" id = "info">
  20. <Li class = "title"> <div> information publicity </div> </LI>
  21. <Li> <a href = "#"> CSS </a> </LI>
  22. <Li> <a href = "http://wallimn.iteye.com"> http://wallimn.iteye.com </a> </LI>
  23. <Li> <a href = "#"> automatic truncation of long texts. Everything is possible. </a> </LI>
  24. <Li class = "tail"> <a href = "#"> more... </a> </LI>
  25. </Ul>
  26. <Br/>
  27. <Input type = "button" value = "style switch" onclick = "doswitch ()"/>
  28. </Body>
  29. </Html>

  CSS file:HTML code

  1. Ul. Column {
  2. Padding: 0;
  3. Margin: 0;
  4. Font: normal 12px "";
  5. Border: 1px solid #000;
  6. }
  7. Ul. Column Li {
  8. Height: 26px;
  9. Line-Height: 26px;
  10. Margin: 0 4px;
  11. Border-bottom: 1px dashed # CCC;
  12. Vertical-align: middle;
  13. Padding-left: 24px;
  14. White-space: nowrap;
  15. Text-overflow: ellipsis;
  16. Overflow: hidden;
  17. }
  18. Ul. Column Li, ul. Column Li. Title Div {
  19. Background: URL ("column.gif") No-Repeat;
  20. }
  21. Ul. Column Li {
  22. Text-Decoration: none;
  23. }
  24. Ul. Column Li A: hover {
  25. Color: red;
  26. }
  27. Ul. Column Li. Title, ul. Column Li. Tail {
  28. Border-width: 0;
  29. }
  30. Ul. Column Li. Title {
  31. Background-repeat: Repeat-X;
  32. Margin: 0;
  33. Padding: 0;
  34. }
  35. Ul. Column Li. Tail {
  36. Text-align: right;
  37. Padding-Right: 12px;
  38. Background-image: none;
  39. }
  40. /* 1 */
  41. Ul. S1 {
  42. Width: 300px;
  43. }
  44. Ul. S1, ul. S1 Li {
  45. Border-color: #2e9803;
  46. }
  47. Ul. S1 Li {
  48. Background-position: 0-52px;
  49. }
  50. Ul. S1 Li. Title {
  51. Background-position: 0-26px;
  52. }
  53. Ul. S1 Li. Title Div {
  54. Background-position: 0 0;
  55. Padding-left: 24px;
  56. }
  57. /* 2 */
  58. Ul. S2 {
  59. Width: 300px;
  60. }
  61. Ul. S2, ul. S2 Li {
  62. Border-color: #9438d4;
  63. }
  64. Ul. S2 Li {
  65. Background-position: 0-130px;
  66. }
  67. Ul. S2 Li. Title {
  68. Background-position: 0-pixel PX;
  69. }
  70. Ul. S2 Li. Title Div {
  71. Background-position: 0-78px;
  72. Padding-left: 24px;
  73. }
  74. /* 3 */
  75. Ul. S3 {
  76. Width: 300px;
  77. }
  78. Ul. S3, ul. S3 Li {
  79. Border-color: #9bb8d2;
  80. }
  81. Ul. S3 Li {
  82. Background-position: 0-208px;
  83. }
  84. Ul. S3 Li. Title {
  85. Background-position: 0-182px;
  86. }
  87. Ul. S3 Li. Title Div {
  88. Background-position: 0-156px;
  89. Padding-left: 24px;
  90. }

  Images used:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.