html 如何将两个元素相邻对齐?[关闭]

jgzswidk  于 2023-11-15  发布在  其他
关注(0)|答案(2)|浏览(145)

已关闭。此问题需要更多focused。目前不接受答案。
**想要改进此问题吗?**更新问题,使其仅关注editing this post的一个问题。

6天前关闭
Improve this question
我正在为一个项目建立一个投资组合网站,我正在努力将页面的元素放在一起,
具体来说,我想我的头,读“客户端网站”对齐旁边的头阅读“计算机科学创造性“这里是我的线框我去了什么。也对如何使代码看起来更好的一般性提示是非常感谢让我知道,如果你需要看到实际的网站

  1. @font-face {
  2. font-family: sourcecodepro;
  3. src: url(fonts/static/SourceCodePro-Regular.ttf);
  4. }
  5. /*.flexbox-conatiner{
  6. display: flex;
  7. flex-direction: row;
  8. }*/
  9. body{
  10. background: #11151C;
  11. display: inline-flex;
  12. flex-direction: column;
  13. flex-wrap: wrap;
  14. }
  15. h1{
  16. font-family: sourcecodepro;
  17. font-size: 25px;
  18. font-weight: 10;
  19. color: #FFFCFF;
  20. margin: 15px;
  21. }
  22. h2 {
  23. font-family: sourcecodepro;
  24. font-size: 25px;
  25. color: #FFFCFF;
  26. }
  27. h3 {
  28. font-family: sourcecodepro;
  29. font-size: 25px;
  30. font-weight: bold;
  31. color: #FFFCFF;
  32. }
  33. .scrollBox{
  34. width: 150px;
  35. height: 150px;
  36. line-height: 3em;
  37. overflow: scroll;
  38. padding: 5px;
  39. font-size: 25px;
  40. font-weight: bold;
  41. font-family: sourcecodepro;
  42. color: #FFFCFF}
  43. /* Add a black background color to the top navigation */
  44. #textbackground{
  45. border-radius: 15px;
  46. background: rgba(212, 246, 178, 0.3);
  47. border-width: 195px;
  48. border-color: #FFFCFF;
  49. padding: 1rem;
  50. width: 600px;
  51. }
  52. p1 {
  53. font-family: sourcecodepro;
  54. font-size: 20px;
  55. color: #FFFCFF;
  56. }
  57. p2{
  58. font-family: sourcecodepro;
  59. font-size: 20px;
  60. color: #FFFCFF;
  61. }
  62. .clientsBox {
  63. position: absolute;
  64. top: 0;
  65. left: 0;
  66. background-color: #333;
  67. opacity: 0.3;
  68. padding: 20px;
  69. color: #fff;
  70. }
  71. .clientsBox h1 {
  72. font-family: sourcecodepro;
  73. font-size: 25px;
  74. font-weight: bold;
  75. }
  76. .topnav {
  77. background-color: #333;
  78. opacity: .3;
  79. overflow: hidden;
  80. }
  81. /* Style the links inside the navigation bar */
  82. .topnav a {
  83. float: left;
  84. color: #f2f2f2;
  85. text-align: center;
  86. padding: 14px 16px;
  87. text-decoration: none;
  88. font-size: 17px;
  89. }
  90. /* Change the color of links on hover */
  91. .topnav a:hover {
  92. background-color: #ddd;
  93. color: black;
  94. }
  95. /* Add a color to the active/current link */
  96. .topnav a.active {
  97. background-color: #04AA6D;
  98. color: white;
  99. }
  100. @media (max-width: 600px) {
  101. .flexbox-container {
  102. flex-direction: column;
  103. /* Change to column for smaller screens */
  104. }
  105. #textbackground {
  106. width: 100%;
  107. /* Adjust the width for smaller screens */
  108. }
  109. }
  110. @media (max-width: 480px) {
  111. h3 {
  112. flex-wrap: wrap;
  113. }
  114. }

个字符
我试过Flexbox的东西,但老实说,我不是很擅长它,我试过常规的CSS定位,但它使标题文本静态,它没有让我将放在标题下的文本被格式化,我试过内联,没有一个工作,也许我只是做得不对

smdncfj3

smdncfj31#

我刚读了你的问题。
你应该首先改变HTMl的结构,并正确地关闭所有的标签。
把你的标题和“客户端站点”代码放在一个主框div中,就像这样,并使用flex属性显示:flex; justify-content:space-between; justify-items-center;
头部和客户端站点都将显示在彼此的前面。

  1. <!DOCTYPE html>
  2. <html lang='en'>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatable" content="IE-edge">
  6. <meta name="viewport" content="width=device-width, inital-scale=1.0">
  7. <title>Document</title>
  8. <link rel="stylesheet" href="/style.css">
  9. <style>
  10. body{
  11. background: #11151C;
  12. color: #fff;
  13. }
  14. .main-box {
  15. display: flex;
  16. justify-content: space-between;
  17. align-items-center;
  18. }
  19. h1{
  20. font-family: sourcecodepro;
  21. font-size: 25px;
  22. font-weight: 10;
  23. color: #FFF;
  24. }
  25. .flexbox-container {
  26. display: flex;
  27. align-items: center;
  28. justify-content: space-between;
  29. }
  30. </style>
  31. </head>
  32. <body>
  33. <div class="main-box">
  34. <div class="topnav">
  35. <a class="active" href="#home">Home</a>
  36. <a href="#news">News</a>
  37. <a href="#contact">Contact</a>
  38. <a href="#about">About</a>
  39. </div>
  40. <p>Client Sites</p>
  41. </div>
  42. <div class="CSmadeC">
  43. <div id="h1" class="flexbox-container">
  44. <h1>Computer Science Made Creative</h1>
  45. </div>
  46. </div>
  47. <div id="textbackground">
  48. <p>
  49. In a world where every website and app looks<br />
  50. the same the goal should be to code creatively,<br />
  51. you give me a vision and with software as my canvas,<br />
  52. ill paint it for you.
  53. </p>
  54. </div>
  55. </body>
  56. </html>

字符串
请尝试使用更多来自w3学校的HTML标签。

展开查看全部
holgip5t

holgip5t2#

我很抱歉,但你的消息是有点不清楚.它看起来像你想让我审查一些代码,但我不知道你指的是哪个代码或你需要帮助的具体问题.你可以请提供更多的上下文或澄清你的问题?在您的html代码中,这个词“客户端网站失踪”.

  1. body{
  2. background: #11151C;
  3. color: #fff;
  4. }
  5. h1{
  6. font-family: sourcecodepro;
  7. font-size: 25px;
  8. font-weight: 10;
  9. color: #FFF;
  10. }
  11. .flexbox-container {
  12. display: flex;
  13. align-items: center;
  14. justify-content: space-between;
  15. }

个字符

展开查看全部

相关问题