javascript 调整大小:水平;我的#left bar

zf2sa74q  于 2023-08-02  发布在  Java
关注(0)|答案(2)|浏览(108)

基本上,我有一个#left-bar div元素,它用作导航栏和一个主题窗口,其中包含一个iFrame。如果您运行该代码段,页面将如下所示:

  1. /* main styling page, empty because there are no pages generated manually so we don't have to deal with this for now */
  2. body{
  3. max-width: 1780px;
  4. font-family:Arial, Helvetica, sans-serif;
  5. }
  6. #top-bar{
  7. background-color:cadetblue;
  8. width: 1830px;
  9. height: 100px;
  10. }
  11. #logo-container{
  12. width: 125px;
  13. height: 100px;
  14. margin-left:15px;
  15. float: left;
  16. }
  17. #logo{
  18. width: 100%;
  19. height: 100%;
  20. }
  21. #logo-container:hover{
  22. cursor: pointer;
  23. }
  24. #search-bar-container{
  25. position: relative;
  26. top: 60px;
  27. left: 220px;
  28. width: 366px;
  29. height: 30px;
  30. }
  31. #search-bar-container > input{
  32. position: absolute;
  33. left: 0px;
  34. width: 100%;
  35. height: 100%;
  36. font-family: 'Times New Roman', Times, serif;
  37. font-size: large;
  38. }
  39. #center-main{
  40. background-color: red;
  41. width: 1830px;
  42. height: 805px;
  43. margin-top: 5px;
  44. position:relative;
  45. outline: thin solid black;
  46. }
  47. .document{
  48. overflow: auto;
  49. }
  50. #left-bar{
  51. background-color: yellow;
  52. width: 220px;
  53. height: 775px;
  54. position: relative;
  55. float: left;
  56. resize: horizontal;
  57. }
  58. #left-bar-icons{
  59. background-color:#b3b4b5;
  60. width: 100%;
  61. height: 30px;
  62. position: relative;
  63. outline: thin solid black;
  64. }
  65. #reset-container{
  66. background-color: #b3b4b5;
  67. width: 20px;
  68. height: 20px;
  69. position: relative;
  70. top: 5px;
  71. left: 195px;
  72. }
  73. #nav-bar-reset-icon{
  74. width: 100%;
  75. height: 100%;
  76. }
  77. #reset-container:hover{
  78. cursor:pointer;
  79. }
  80. #toc{
  81. background-color: lightgray;
  82. border-right: thin solid black;
  83. width:99.5%;
  84. height:770px;
  85. overflow: auto;
  86. padding-top: 5px;
  87. }
  88. .content{
  89. padding: 3px;
  90. margin-left: 5px;
  91. }
  92. .content-drop{
  93. float:left;
  94. }
  95. .content-drop:hover{
  96. cursor: pointer;
  97. }
  98. .content-link{
  99. color: black;
  100. text-decoration: none;
  101. }
  102. .l1-drop-container{
  103. margin-left: 20px;
  104. margin-top: 4px;
  105. width: 100%;;
  106. display: none;
  107. }
  108. .l1-content-link{
  109. display: inline-block;
  110. text-decoration: none;
  111. color: black;
  112. }
  113. .l2-drop-container{
  114. margin-left: 30px;
  115. margin-top: 4px;
  116. width: 100%;
  117. display:none;
  118. }
  119. .l2-content-link{
  120. text-decoration: none;
  121. color: black;
  122. margin-bottom: 5px;
  123. }
  124. .l1-content-drop:hover{
  125. cursor:pointer;
  126. }
  127. #topic-window{
  128. background-color:#e9e9ed;
  129. width: 1610px;
  130. height: 100%;
  131. position:relative;
  132. float:right;
  133. outline: thin solid black;
  134. }
  135. #docWindow{
  136. width: 100%;
  137. height: 100%;
  138. position:relative;
  139. float: right;
  140. }
  141. .show-l2-content{
  142. display: block;
  143. }
  144. .show-left-bar{
  145. display: block;
  146. }

个字符
我尝试在CSS文件中将resize: horizontal;添加到#left-bar中,但是当添加resize时,我无法真正看到弹出在其中一个角落的调整大小按钮。
我在想问题可能是一些元素相互重叠或什么的,但即使如此,我不知道为什么和什么会重叠。
希望你能帮忙。

xvw2m8pv

xvw2m8pv1#

问题是,当你调整大小时,你还必须做一个溢出:auto在同一元素上。
所以只要加上一个overflow:自动到#左栏就可以了。

  1. /* main styling page, empty because there are no pages generated manually so we don't have to deal with this for now */
  2. body{
  3. max-width: 1780px;
  4. font-family:Arial, Helvetica, sans-serif;
  5. }
  6. #top-bar{
  7. background-color:cadetblue;
  8. width: 1830px;
  9. height: 100px;
  10. }
  11. #logo-container{
  12. width: 125px;
  13. height: 100px;
  14. margin-left:15px;
  15. float: left;
  16. }
  17. #logo{
  18. width: 100%;
  19. height: 100%;
  20. }
  21. #logo-container:hover{
  22. cursor: pointer;
  23. }
  24. #search-bar-container{
  25. position: relative;
  26. top: 60px;
  27. left: 220px;
  28. width: 366px;
  29. height: 30px;
  30. }
  31. #search-bar-container > input{
  32. position: absolute;
  33. left: 0px;
  34. width: 100%;
  35. height: 100%;
  36. font-family: 'Times New Roman', Times, serif;
  37. font-size: large;
  38. }
  39. #center-main{
  40. background-color: red;
  41. width: 1830px;
  42. height: 805px;
  43. margin-top: 5px;
  44. position:relative;
  45. outline: thin solid black;
  46. }
  47. .document{
  48. overflow: auto;
  49. }
  50. #left-bar{
  51. background-color: yellow;
  52. width: 220px;
  53. height: 775px;
  54. position: relative;
  55. float: left;
  56. resize: horizontal;
  57. overflow: auto;
  58. }
  59. #left-bar-icons{
  60. background-color:#b3b4b5;
  61. width: 100%;
  62. height: 30px;
  63. position: relative;
  64. outline: thin solid black;
  65. }
  66. #reset-container{
  67. background-color: #b3b4b5;
  68. width: 20px;
  69. height: 20px;
  70. position: relative;
  71. top: 5px;
  72. left: 195px;
  73. }
  74. #nav-bar-reset-icon{
  75. width: 100%;
  76. height: 100%;
  77. }
  78. #reset-container:hover{
  79. cursor:pointer;
  80. }
  81. #toc{
  82. background-color: lightgray;
  83. border-right: thin solid black;
  84. width:99.5%;
  85. height:770px;
  86. overflow: auto;
  87. padding-top: 5px;
  88. }
  89. .content{
  90. padding: 3px;
  91. margin-left: 5px;
  92. }
  93. .content-drop{
  94. float:left;
  95. }
  96. .content-drop:hover{
  97. cursor: pointer;
  98. }
  99. .content-link{
  100. color: black;
  101. text-decoration: none;
  102. }
  103. .l1-drop-container{
  104. margin-left: 20px;
  105. margin-top: 4px;
  106. width: 100%;;
  107. display: none;
  108. }
  109. .l1-content-link{
  110. display: inline-block;
  111. text-decoration: none;
  112. color: black;
  113. }
  114. .l2-drop-container{
  115. margin-left: 30px;
  116. margin-top: 4px;
  117. width: 100%;
  118. display:none;
  119. }
  120. .l2-content-link{
  121. text-decoration: none;
  122. color: black;
  123. margin-bottom: 5px;
  124. }
  125. .l1-content-drop:hover{
  126. cursor:pointer;
  127. }
  128. #topic-window{
  129. background-color:#e9e9ed;
  130. width: 1610px;
  131. height: 100%;
  132. position:relative;
  133. float:right;
  134. outline: thin solid black;
  135. }
  136. #docWindow{
  137. width: 100%;
  138. height: 100%;
  139. position:relative;
  140. float: right;
  141. }
  142. .show-l2-content{
  143. display: block;
  144. }
  145. .show-left-bar{
  146. display: block;
  147. }

个字符
但正如你所看到的,这不是你想要的行为。
试试这个codepen
(Note:为了简单起见,我减少了HTML和CSS,但实现方式保持不变。)

展开查看全部
nfg76nw0

nfg76nw02#

我发现问题了。和我想的一样简单。
我只是不得不让overflow: visible;字面上任何,但overflow: visible;。将其更改为overflow: auto;工作,我没有测试其他人,但我打赌他们也工作。

相关问题