css 如何在div标签下放置文本?

cmssoen2  于 2023-11-19  发布在  其他
关注(0)|答案(3)|浏览(124)

我用div在表格的两边做了两个图像,但是一旦div结束了,我用<p>输入的文本就会出现在div的上面,尽管在代码的后面。我希望文本出现在表格的下面。

  1. <!Doctype html>
  2. <html>
  3. <head>
  4. <link rel = "stylesheet" type = "text/css" href="website.css"/>
  5. <title> Stoge Guitars </title>
  6. </head>
  7. <body>
  8. <div id = "container">
  9. <div id = "X">
  10. <img src= "images/workshop.png" id = "guitar">
  11. </div>
  12. <div id = "C">
  13. <img src= "images/workshop.png" id = "guitar2">
  14. </div>
  15. <div id = "V">
  16. <table>
  17. <tr>
  18. <th colspan = "5" id = "STOGEGUITARS"> STOGE GUITARS </th>
  19. </tr>
  20. <tr>
  21. <th>Home</th>
  22. <th>Our Custom Guitars</th>
  23. <th>Forum</th>
  24. <th>Workshop Gallery</th>
  25. <th>Contact Us</th>
  26. </tr>
  27. </table>
  28. </div>
  29. </div>
  30. <p> This should be below the table </p>
  31. </body>

字符串

CSS

  1. body
  2. {
  3. Background-image: url("http://images.epiphone.com.s3.amazonaws.com/Products/Les-Paul/Les-Paul- Standard-Plustop-PRO/Gallery/POP_LPSTDPLUSPRO-HB.jpg");
  4. background-size: 100% 100%;
  5. background-repeat: no-repeat;
  6. background-size: cover;
  7. }
  8. #STOGEGUITARS
  9. {
  10. font-size: 20pt;
  11. font-family: "Times New Roman", Times, serif;
  12. font-style: italic;
  13. }
  14. table, th, td
  15. {
  16. border: 1px solid black;
  17. }
  18. table
  19. {
  20. width: 60%;
  21. margin-left: 20%;
  22. margin-right: 20%;
  23. position: fixed;
  24. }
  25. #guitar
  26. {
  27. float: left;
  28. }
  29. #guitar2
  30. {
  31. float: right;
  32. }
  33. #guitar
  34. {
  35. width: 19%;
  36. height: 100%;
  37. position: fixed;
  38. }
  39. #guitar2
  40. {
  41. width: 19%;
  42. height: 100%;
  43. position: fixed;
  44. right: 0px;
  45. }
  46. p
  47. {
  48. border: 0px;
  49. text-align: left;
  50. }


如果我犯了一个愚蠢的错误,我很抱歉,我只有16岁,是HTML和CSS的新手。

eulz3vhy

eulz3vhy1#

检查此fiddle

  1. position: relative;

字符串
是你要找的,位置固定使其他元素忽略元素的位置

cdmah0mi

cdmah0mi2#

我修改了你的HTML和CSS代码:

  1. body {
  2. Background-image: url("http://images.epiphone.com.s3.amazonaws.com/Products/Les-Paul/Les-Paul- Standard-Plustop-PRO/Gallery/POP_LPSTDPLUSPRO-HB.jpg");
  3. background-size: 100% 100%;
  4. background-repeat: no-repeat;
  5. background-size: cover;
  6. margin:0;
  7. }
  8. #STOGEGUITARS {
  9. font-size: 20pt;
  10. font-family: "Times New Roman", Times, serif;
  11. font-style: italic;
  12. }
  13. table, th, td {
  14. border: 1px solid black;
  15. }
  16. table {
  17. width:100%;
  18. }
  19. #X {
  20. display:inline-block;
  21. position: fixed;
  22. left:0px;
  23. top:0px;
  24. width: 19%;
  25. height: 100%;
  26. }
  27. #V {
  28. margin:0;
  29. display:inline-block;
  30. top:0px;
  31. width: 62%;
  32. height: 100%;
  33. border:1px solid red; /* Remove this line it's just for checking boundaries */
  34. }
  35. #C {
  36. display:inline-block;
  37. position: fixed;
  38. right:0px;
  39. top:0px;
  40. width: 19%;
  41. height: 100%;
  42. }
  43. img {
  44. width:100%;
  45. height:100%;
  46. }
  47. p {
  48. position:relative;
  49. text-align:left;
  50. }

个字符

展开查看全部
guykilcj

guykilcj3#

只是字面上把一个权利下,你想把东西下,它做了刚才,它的工作!:D

相关问题