这是一个关于 div 内 img 比例的 CSS 问题。

huangapple go评论85阅读模式
英文:

This is a css question about the ratio of img inside the div

问题

以下是代码的翻译部分:

  1. .gridContainer {
  2. display: grid;
  3. grid-template-columns: 70% 29.5%;
  4. grid-template-rows: repeat(auto-fit, minmax(100px, 1fr));
  5. grid-gap: 10px;
  6. height: 90vh;
  7. overflow: hidden;
  8. position: relative;
  9. background-color: #ffffffc5;
  10. padding: 10px;
  11. }
  12. /* ... 其他 CSS 样式 ... */
  13. .responsiveImage {
  14. display: block;
  15. width: 100%;
  16. height: 100%;
  17. object-fit: contain;
  18. max-width: 100%;
  19. max-height: 100%;
  20. }
  21. /* ... 更多 CSS 样式 ... */
  22. @keyframes blinker {
  23. 50% {
  24. opacity: 10;
  25. background-color: #e91e63;
  26. }
  27. }
  28. @keyframes blinkerblue {
  29. 50% {
  30. opacity: 10;
  31. background-color: #0186f3c5;
  32. }
  33. }
  34. @keyframes slideIn {
  35. 0% {
  36. transform: translateY(-100%);
  37. opacity: 0;
  38. }
  39. 100% {
  40. transform: translateY(0);
  41. opacity: 1;
  42. }
  43. }
  44. @keyframes slideOut {
  45. 0% {
  46. transform: translateY(0);
  47. opacity: 1;
  48. }
  49. 100% {
  50. transform: translateY(100%);
  51. opacity: 0;
  52. }
  53. }
  1. <div class="gridContainer">
  2. <div class="gridItem item1">
  3. <div class="selectModeContainer">
  4. <!-- selectModeContainer 内容 -->
  5. </div>
  6. <div class="boxesContainer">
  7. <!-- boxesContainer 内容 -->
  8. </div>
  9. <div class="gageContainer">
  10. <!-- gageContainer 内容 -->
  11. </div>
  12. </div>
  13. <div class="gridItem item2">
  14. <div class="item"></div>
  15. <div class="item"></div>
  16. <div class="item"></div>
  17. <div class="item"></div>
  18. <div class="item"></div>
  19. <div class="item"></div>
  20. </div>
  21. <div class="gridItem item3">
  22. <!-- item3 内容 -->
  23. <div class="gridImage">
  24. <div class="test">
  25. <img src="https://picsum.photos/1600/900" alt="Responsive Image" class="responsiveImage" />
  26. </div>
  27. </div>
  28. </div>
  29. <div class="gridItem item4">
  30. <div class="pump">
  31. <!-- pump 内容 -->
  32. </div>
  33. </div>
  34. <!-- 其他 gridItem 的内容 -->
  35. </div>

希望这对你有所帮助!如果有任何其他问题,请随时提出。

英文:

这是一个关于 div 内 img 比例的 CSS 问题。
↑ this is OK
这是一个关于 div 内 img 比例的 CSS 问题。
↑ this is OK
这是一个关于 div 内 img 比例的 CSS 问题。
↑ this is not ok it's too bad ,The reason why I asked

这是一个关于 div 内 img 比例的 CSS 问题。

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

  1. .gridContainer {
  2. display: grid;
  3. grid-template-columns: 70% 29.5%;
  4. grid-template-rows: repeat(auto-fit, minmax(100px, 1fr));
  5. grid-gap: 10px;
  6. height: 90vh;
  7. overflow: hidden;
  8. position: relative;
  9. background-color: #ffffffc5;
  10. padding: 10px;
  11. }
  12. .gridItem {
  13. padding: 10px;
  14. display: flex;
  15. flex-direction: row;
  16. }
  17. .item1 {
  18. background-color: #ffffffc5;
  19. border-radius: 10px;
  20. border: 2px solid rgb(5, 53, 245);
  21. display: flex;
  22. grid-row: 1 / span 1;
  23. grid-column: 1 / 1;
  24. min-height: 130px;
  25. }
  26. .selectModeContainer {
  27. width: 45%;
  28. display: flex;
  29. flex-direction: column;
  30. align-items: center;
  31. justify-content: center;
  32. gap: 1px;
  33. }
  34. .boxesContainer {
  35. width: 25%;
  36. display: flex;
  37. flex-direction: column;
  38. align-items: flex-end;
  39. margin-right: 20px;
  40. }
  41. .gageContainer {
  42. width: 30%;
  43. display: flex;
  44. gap: 5px;
  45. }
  46. .statusbox {
  47. color: #fffdfd;
  48. border-radius: 5px;
  49. border: 2px solid rgb(0, 101, 252);
  50. background-color: #0186f3c5;
  51. flex: 1;
  52. margin-right: 5px;
  53. margin: 2px;
  54. width: 12em;
  55. height: 10rem;
  56. display: flex;
  57. justify-content: flex-end;
  58. align-items: center;
  59. text-align: right;
  60. padding: 1px;
  61. }
  62. .item2 {
  63. grid-row: 1 / span 1;
  64. grid-column: 2 / 3;
  65. display: grid;
  66. grid-template-columns: repeat(3, 1fr);
  67. grid-template-rows: repeat(2, 1fr);
  68. gap: 10px;
  69. z-index: 1;
  70. background-color: #ffffffc5;
  71. border-radius: 10px;
  72. border: 2px solid rgb(5, 53, 245);
  73. min-width: 378px;
  74. }
  75. .item2 .item {
  76. display: flex;
  77. justify-content: center;
  78. align-items: center;
  79. border: 2px solid rgba(5, 53, 245, 0.349);
  80. background-color: #ffffffc5;
  81. font-size: 16px;
  82. text-transform: uppercase;
  83. letter-spacing: 2px;
  84. transition: background-color 0.3s ease;
  85. width: 100%;
  86. height: 100%;
  87. z-index: 1;
  88. border-radius: 10px;
  89. min-width: 107px;
  90. }
  91. .item3 {
  92. grid-row: 2 / span 5;
  93. grid-column: 1 / span 1;
  94. display: grid;
  95. width: auto;
  96. height: auto;
  97. background-color: #ffffffc5;
  98. border-radius: 10px;
  99. border: 2px solid rgb(5, 53, 245);
  100. }
  101. .gridImage {
  102. display: flex;
  103. position: relative;
  104. justify-content: center;
  105. border-radius: 10px;
  106. align-items: center;
  107. justify-items: center;
  108. justify-content: center;
  109. }
  110. .test {
  111. justify-content: center;
  112. position: relative;
  113. align-items: center;
  114. justify-items: center;
  115. justify-content: center;
  116. border-radius: 10px;
  117. width: fit-content;
  118. height: fit-content;
  119. max-width: 100%;
  120. max-height: 100%;
  121. margin: auto;
  122. }
  123. .responsiveImage {
  124. display: block;
  125. width: 100%;
  126. height: 100%;
  127. object-fit: contain;
  128. max-width: 100%;
  129. max-height: 100%;
  130. }
  131. .test::before {
  132. content: &quot;&quot;;
  133. position: absolute;
  134. top: 0;
  135. left: 0;
  136. right: 0;
  137. bottom: 0;
  138. z-index: 0;
  139. width: 100%;
  140. height: 100%;
  141. /* max-width: 100%; */
  142. border: 1px solid #ddd;
  143. background-image: linear-gradient(to right, #000000 1px, transparent 1px),
  144. linear-gradient(to bottom, #000000 1px, transparent 1px);
  145. background-size: 40px 40px;
  146. background-position: 0 0, 0 0;
  147. }
  148. .item4 {
  149. grid-row: 2 / span 3;
  150. grid-column: 2 / span 1;
  151. display: grid;
  152. grid-template-rows: auto 10%;
  153. background-color: #ffffffc5;
  154. gap: 10px;
  155. border-radius: 10px;
  156. overflow: hidden;
  157. border-radius: 10px;
  158. border: 2px solid rgb(5, 53, 245);
  159. /* min-height: 368px; */
  160. }
  161. .item&gt;div {
  162. flex: 1;
  163. }
  164. .item10 {
  165. display: grid;
  166. grid-row: 5 / span 2;
  167. grid-column: 2 / span 1;
  168. background-color: #ffffffc5;
  169. border-radius: 10px;
  170. border: 2px solid rgb(5, 53, 245);
  171. }
  172. .pump {
  173. display: flex;
  174. }
  175. .item5,
  176. .item6,
  177. .item7,
  178. .item8,
  179. .item9,
  180. .item11,
  181. .item12 {
  182. display: none;
  183. }
  184. .accordion-collapse.collapse.show {
  185. max-height: fit-content;
  186. }
  187. .accordion-body {
  188. max-height: fit-content;
  189. padding: var(--bs-accordion-body-padding-y) var(--bs-accordion-body-padding-x);
  190. }
  191. .button {
  192. display: block;
  193. border: 2px solid #000;
  194. background-color: #ffeeca;
  195. font-size: 16px;
  196. text-align: center;
  197. text-transform: uppercase;
  198. letter-spacing: 2px;
  199. transition: background-color 0.3s ease;
  200. width: 100%;
  201. height: 100%;
  202. border-radius: 15px;
  203. }
  204. .blink {
  205. animation: blinker 3s linear infinite;
  206. color: #fff;
  207. z-index: 1;
  208. }
  209. .blinkblue {
  210. animation: blinkerblue 3s linear infinite;
  211. color: #fff;
  212. z-index: 1;
  213. }
  214. .button[disabled] {
  215. background-color: #ccc;
  216. color: #999;
  217. cursor: not-allowed;
  218. border-radius: 15px;
  219. border: 2px solid #000;
  220. }
  221. @keyframes blinker {
  222. 50% {
  223. opacity: 10;
  224. background-color: #e91e63;
  225. }
  226. }
  227. @keyframes blinkerblue {
  228. 50% {
  229. opacity: 10;
  230. background-color: #0186f3c5;
  231. }
  232. }
  233. @keyframes slideIn {
  234. 0% {
  235. transform: translateY(-100%);
  236. opacity: 0;
  237. }
  238. 100% {
  239. transform: translateY(0);
  240. opacity: 1;
  241. }
  242. }
  243. @keyframes slideOut {
  244. 0% {
  245. transform: translateY(0);
  246. opacity: 1;
  247. }
  248. 100% {
  249. transform: translateY(100%);
  250. opacity: 0;
  251. }
  252. }

<!-- language: lang-html -->

  1. &lt;div class=&quot;gridContainer&quot;&gt;
  2. &lt;div class=&quot;gridItem item1&quot;&gt;
  3. &lt;div class=&quot;selectModeContainer&quot;&gt;
  4. &lt;!-- Content for selectModeContainer --&gt;
  5. &lt;/div&gt;
  6. &lt;div class=&quot;boxesContainer&quot;&gt;
  7. &lt;!-- Content for boxesContainer --&gt;
  8. &lt;/div&gt;
  9. &lt;div class=&quot;gageContainer&quot;&gt;
  10. &lt;!-- Content for gageContainer --&gt;
  11. &lt;/div&gt;
  12. &lt;/div&gt;
  13. &lt;div class=&quot;gridItem item2&quot;&gt;
  14. &lt;div class=&quot;item&quot;&gt;&lt;/div&gt;
  15. &lt;div class=&quot;item&quot;&gt;&lt;/div&gt;
  16. &lt;div class=&quot;item&quot;&gt;&lt;/div&gt;
  17. &lt;div class=&quot;item&quot;&gt;&lt;/div&gt;
  18. &lt;div class=&quot;item&quot;&gt;&lt;/div&gt;
  19. &lt;div class=&quot;item&quot;&gt;&lt;/div&gt;
  20. &lt;/div&gt;
  21. &lt;div class=&quot;gridItem item3&quot;&gt;
  22. &lt;!-- Content for item3 --&gt;
  23. &lt;div class=&quot;gridImage&quot;&gt;
  24. &lt;div class=&quot;test&quot;&gt;
  25. &lt;img
  26. src=&quot;https://picsum.photos/1600/900&quot;
  27. alt=&quot;Responsive Image&quot;
  28. class=&quot;responsiveImage&quot;
  29. /&gt;
  30. &lt;/div&gt;
  31. &lt;/div&gt;
  32. &lt;/div&gt;
  33. &lt;div class=&quot;gridItem item4&quot;&gt;
  34. &lt;div class=&quot;pump&quot;&gt;
  35. &lt;!-- Content for pump --&gt;
  36. &lt;/div&gt;
  37. &lt;/div&gt;
  38. &lt;div class=&quot;gridItem item5&quot;&gt;
  39. &lt;!-- Content for item5 --&gt;
  40. &lt;/div&gt;
  41. &lt;div class=&quot;gridItem item6&quot;&gt;
  42. &lt;!-- Content for item6 --&gt;
  43. &lt;/div&gt;
  44. &lt;div class=&quot;gridItem item7&quot;&gt;
  45. &lt;!-- Content for item7 --&gt;
  46. &lt;/div&gt;
  47. &lt;div class=&quot;gridItem item8&quot;&gt;
  48. &lt;!-- Content for item8 --&gt;
  49. &lt;/div&gt;
  50. &lt;div class=&quot;gridItem item9&quot;&gt;
  51. &lt;!-- Content for item9 --&gt;
  52. &lt;/div&gt;
  53. &lt;div class=&quot;gridItem item10&quot;&gt;
  54. &lt;!-- Content for item10 --&gt;
  55. &lt;/div&gt;
  56. &lt;div class=&quot;gridItem item11&quot;&gt;
  57. &lt;!-- Content for item11 --&gt;
  58. &lt;/div&gt;
  59. &lt;div class=&quot;gridItem item12&quot;&gt;
  60. &lt;!-- Content for item12 --&gt;
  61. &lt;/div&gt;
  62. &lt;/div&gt;

<!-- end snippet -->

Even if it shrinks horizontally or vertically, I hope there is an image in GridImage.
It's a coordinate calculation
The test must be the same size as the response image.
I don't know what to do because it's a condition where you can never cut an image with overFlow or make a scroll..

I tried to limit the width and height to fit-content, etc.

I adjusted the ratio of max-width, max-height, etc. top: 50%;
left: 50%;
transform: translate (-50%, -50%); I've also tried it

This shows the image too small.

答案1

得分: 1

我认为这样更好。我从.item3中删除了display: grid,同时也删除了图像周围一些多余的包装div

  1. .gridContainer {
  2. /* CSS样式内容 */
  3. }
  4. .gridItem {
  5. /* CSS样式内容 */
  6. }
  7. .item1 {
  8. /* CSS样式内容 */
  9. }
  10. .selectModeContainer {
  11. /* CSS样式内容 */
  12. }
  13. .boxesContainer {
  14. /* CSS样式内容 */
  15. }
  16. .gageContainer {
  17. /* CSS样式内容 */
  18. }
  19. .item2 {
  20. /* CSS样式内容 */
  21. }
  22. .item2 .item {
  23. /* CSS样式内容 */
  24. }
  25. .item3 {
  26. /* CSS样式内容 */
  27. }
  28. .responsiveImage {
  29. /* CSS样式内容 */
  30. }
  31. .item4 {
  32. /* CSS样式内容 */
  33. }
  34. .item>div {
  35. /* CSS样式内容 */
  36. }
  37. .item10 {
  38. /* CSS样式内容 */
  39. }
  40. .pump {
  41. /* CSS样式内容 */
  42. }
  43. .item5,
  44. .item6,
  45. .item7,
  46. .item8,
  47. .item9,
  48. .item11,
  49. .item12 {
  50. /* CSS样式内容 */
  51. }
  52. .accordion-collapse.collapse.show {
  53. /* CSS样式内容 */
  54. }
  55. .accordion-body {
  56. /* CSS样式内容 */
  57. }
  58. .button {
  59. /* CSS样式内容 */
  60. }
  61. .blink {
  62. /* CSS样式内容 */
  63. }
  64. .blinkblue {
  65. /* CSS样式内容 */
  66. }
  67. .button[disabled] {
  68. /* CSS样式内容 */
  69. }
  70. @keyframes blinker {
  71. /* CSS样式内容 */
  72. }
  73. @keyframes blinkerblue {
  74. /* CSS样式内容 */
  75. }
  76. @keyframes slideIn {
  77. /* CSS样式内容 */
  78. }
  79. @keyframes slideOut {
  80. /* CSS样式内容 */
  81. }
  1. <div class="gridContainer">
  2. <div class="gridItem item1">
  3. <div class="selectModeContainer">
  4. <!-- selectModeContainer的内容 -->
  5. </div>
  6. <div class="boxesContainer">
  7. <!-- boxesContainer的内容 -->
  8. </div>
  9. <div class="gageContainer">
  10. <!-- gageContainer的内容 -->
  11. </div>
  12. </div>
  13. <div class="gridItem item2">
  14. <div class="item"></div>
  15. <div class="item"></div>
  16. <div class="item"></div>
  17. <div class="item"></div>
  18. <div class="item"></div>
  19. <div class="item"></div>
  20. </div>
  21. <div class="gridItem item3">
  22. <!-- item3的内容 -->
  23. <img src="https://picsum.photos/1600/900" class="responsiveImage">
  24. </div>
  25. <div class="gridItem item4">
  26. <div class="pump">
  27. <!-- pump的内容 -->
  28. </div>
  29. </div>
  30. <div class="gridItem item5">
  31. <!-- item5的内容 -->
  32. </div>
  33. <div class="gridItem item6">
  34. <!-- item6的内容 -->
  35. </div>
  36. <div class="gridItem item7">
  37. <!-- item7的内容 -->
  38. </div>
  39. <div class="gridItem item8">
  40. <!-- item8的内容 -->
  41. </div>
  42. <div class="gridItem item9">
  43. <!-- item9的内容 -->
  44. </div>
  45. <div class="gridItem item10">
  46. <!-- item10的内容 -->
  47. </div>
  48. <div class="gridItem item11">
  49. <!-- item11的内容 -->
  50. </div>
  51. <div class="gridItem item12">
  52. <!-- item12的内容 -->
  53. </div>
  54. </div>
英文:

I think this is better. I removed display: grid from .item3 as well as some superfluous wrapper divs around the image.

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

  1. .gridContainer {
  2. display: grid;
  3. grid-template-columns: 70% 29.5%;
  4. grid-template-rows: repeat(auto-fit, minmax(100px, 1fr));
  5. grid-gap: 10px;
  6. height: 90vh;
  7. overflow: hidden;
  8. position: relative;
  9. background-color: #ffffffc5;
  10. padding: 10px;
  11. }
  12. .gridItem {
  13. padding: 10px;
  14. display: flex;
  15. flex-direction: row;
  16. }
  17. .item1 {
  18. background-color: #ffffffc5;
  19. border-radius: 10px;
  20. border: 2px solid rgb(5, 53, 245);
  21. display: flex;
  22. grid-row: 1 / span 1;
  23. grid-column: 1 / 1;
  24. min-height: 130px;
  25. }
  26. .selectModeContainer {
  27. width: 45%;
  28. display: flex;
  29. flex-direction: column;
  30. align-items: center;
  31. justify-content: center;
  32. gap: 1px;
  33. }
  34. .boxesContainer {
  35. width: 25%;
  36. display: flex;
  37. flex-direction: column;
  38. align-items: flex-end;
  39. margin-right: 20px;
  40. }
  41. .gageContainer {
  42. width: 30%;
  43. display: flex;
  44. gap: 5px;
  45. }
  46. .statusbox {
  47. color: #fffdfd;
  48. border-radius: 5px;
  49. border: 2px solid rgb(0, 101, 252);
  50. background-color: #0186f3c5;
  51. flex: 1;
  52. margin-right: 5px;
  53. margin: 2px;
  54. width: 12em;
  55. height: 10rem;
  56. display: flex;
  57. justify-content: flex-end;
  58. align-items: center;
  59. text-align: right;
  60. padding: 1px;
  61. }
  62. .item2 {
  63. grid-row: 1 / span 1;
  64. grid-column: 2 / 3;
  65. display: grid;
  66. grid-template-columns: repeat(3, 1fr);
  67. grid-template-rows: repeat(2, 1fr);
  68. gap: 10px;
  69. z-index: 1;
  70. background-color: #ffffffc5;
  71. border-radius: 10px;
  72. border: 2px solid rgb(5, 53, 245);
  73. min-width: 378px;
  74. }
  75. .item2 .item {
  76. display: flex;
  77. justify-content: center;
  78. align-items: center;
  79. border: 2px solid rgba(5, 53, 245, 0.349);
  80. background-color: #ffffffc5;
  81. font-size: 16px;
  82. text-transform: uppercase;
  83. letter-spacing: 2px;
  84. transition: background-color 0.3s ease;
  85. width: 100%;
  86. height: 100%;
  87. z-index: 1;
  88. border-radius: 10px;
  89. min-width: 107px;
  90. }
  91. .item3 {
  92. grid-row: 2 / span 5;
  93. grid-column: 1 / span 1;
  94. background-color: #ffffffc5;
  95. border-radius: 10px;
  96. border: 2px solid rgb(5, 53, 245);
  97. }
  98. .responsiveImage {
  99. display: block;
  100. width: 100%;
  101. height: 100%;
  102. object-fit: contain;
  103. }
  104. .item4 {
  105. grid-row: 2 / span 3;
  106. grid-column: 2 / span 1;
  107. display: grid;
  108. grid-template-rows: auto 10%;
  109. background-color: #ffffffc5;
  110. gap: 10px;
  111. border-radius: 10px;
  112. overflow: hidden;
  113. border-radius: 10px;
  114. border: 2px solid rgb(5, 53, 245);
  115. /* min-height: 368px; */
  116. }
  117. .item&gt;div {
  118. flex: 1;
  119. }
  120. .item10 {
  121. display: grid;
  122. grid-row: 5 / span 2;
  123. grid-column: 2 / span 1;
  124. background-color: #ffffffc5;
  125. border-radius: 10px;
  126. border: 2px solid rgb(5, 53, 245);
  127. }
  128. .pump {
  129. display: flex;
  130. }
  131. .item5,
  132. .item6,
  133. .item7,
  134. .item8,
  135. .item9,
  136. .item11,
  137. .item12 {
  138. display: none;
  139. }
  140. .accordion-collapse.collapse.show {
  141. max-height: fit-content;
  142. }
  143. .accordion-body {
  144. max-height: fit-content;
  145. padding: var(--bs-accordion-body-padding-y) var(--bs-accordion-body-padding-x);
  146. }
  147. .button {
  148. display: block;
  149. border: 2px solid #000;
  150. background-color: #ffeeca;
  151. font-size: 16px;
  152. text-align: center;
  153. text-transform: uppercase;
  154. letter-spacing: 2px;
  155. transition: background-color 0.3s ease;
  156. width: 100%;
  157. height: 100%;
  158. border-radius: 15px;
  159. }
  160. .blink {
  161. animation: blinker 3s linear infinite;
  162. color: #fff;
  163. z-index: 1;
  164. }
  165. .blinkblue {
  166. animation: blinkerblue 3s linear infinite;
  167. color: #fff;
  168. z-index: 1;
  169. }
  170. .button[disabled] {
  171. background-color: #ccc;
  172. color: #999;
  173. cursor: not-allowed;
  174. border-radius: 15px;
  175. border: 2px solid #000;
  176. }
  177. @keyframes blinker {
  178. 50% {
  179. opacity: 10;
  180. background-color: #e91e63;
  181. }
  182. }
  183. @keyframes blinkerblue {
  184. 50% {
  185. opacity: 10;
  186. background-color: #0186f3c5;
  187. }
  188. }
  189. @keyframes slideIn {
  190. 0% {
  191. transform: translateY(-100%);
  192. opacity: 0;
  193. }
  194. 100% {
  195. transform: translateY(0);
  196. opacity: 1;
  197. }
  198. }
  199. @keyframes slideOut {
  200. 0% {
  201. transform: translateY(0);
  202. opacity: 1;
  203. }
  204. 100% {
  205. transform: translateY(100%);
  206. opacity: 0;
  207. }
  208. }

<!-- language: lang-html -->

  1. &lt;div class=&quot;gridContainer&quot;&gt;
  2. &lt;div class=&quot;gridItem item1&quot;&gt;
  3. &lt;div class=&quot;selectModeContainer&quot;&gt;
  4. &lt;!-- Content for selectModeContainer --&gt;
  5. &lt;/div&gt;
  6. &lt;div class=&quot;boxesContainer&quot;&gt;
  7. &lt;!-- Content for boxesContainer --&gt;
  8. &lt;/div&gt;
  9. &lt;div class=&quot;gageContainer&quot;&gt;
  10. &lt;!-- Content for gageContainer --&gt;
  11. &lt;/div&gt;
  12. &lt;/div&gt;
  13. &lt;div class=&quot;gridItem item2&quot;&gt;
  14. &lt;div class=&quot;item&quot;&gt;&lt;/div&gt;
  15. &lt;div class=&quot;item&quot;&gt;&lt;/div&gt;
  16. &lt;div class=&quot;item&quot;&gt;&lt;/div&gt;
  17. &lt;div class=&quot;item&quot;&gt;&lt;/div&gt;
  18. &lt;div class=&quot;item&quot;&gt;&lt;/div&gt;
  19. &lt;div class=&quot;item&quot;&gt;&lt;/div&gt;
  20. &lt;/div&gt;
  21. &lt;div class=&quot;gridItem item3&quot;&gt;
  22. &lt;!-- Content for item3 --&gt;
  23. &lt;img src=&quot;https://picsum.photos/1600/900&quot; class=&quot;responsiveImage&quot;&gt;
  24. &lt;/div&gt;
  25. &lt;div class=&quot;gridItem item4&quot;&gt;
  26. &lt;div class=&quot;pump&quot;&gt;
  27. &lt;!-- Content for pump --&gt;
  28. &lt;/div&gt;
  29. &lt;/div&gt;
  30. &lt;div class=&quot;gridItem item5&quot;&gt;
  31. &lt;!-- Content for item5 --&gt;
  32. &lt;/div&gt;
  33. &lt;div class=&quot;gridItem item6&quot;&gt;
  34. &lt;!-- Content for item6 --&gt;
  35. &lt;/div&gt;
  36. &lt;div class=&quot;gridItem item7&quot;&gt;
  37. &lt;!-- Content for item7 --&gt;
  38. &lt;/div&gt;
  39. &lt;div class=&quot;gridItem item8&quot;&gt;
  40. &lt;!-- Content for item8 --&gt;
  41. &lt;/div&gt;
  42. &lt;div class=&quot;gridItem item9&quot;&gt;
  43. &lt;!-- Content for item9 --&gt;
  44. &lt;/div&gt;
  45. &lt;div class=&quot;gridItem item10&quot;&gt;
  46. &lt;!-- Content for item10 --&gt;
  47. &lt;/div&gt;
  48. &lt;div class=&quot;gridItem item11&quot;&gt;
  49. &lt;!-- Content for item11 --&gt;
  50. &lt;/div&gt;
  51. &lt;div class=&quot;gridItem item12&quot;&gt;
  52. &lt;!-- Content for item12 --&gt;
  53. &lt;/div&gt;
  54. &lt;/div&gt;

<!-- end snippet -->

答案2

得分: 0

如果它不会自动运行...我通过指定每一个来制定了一个临时处方。我希望它能够自动运行...

英文:

这是一个关于 div 内 img 比例的 CSS 问题。

If it doesn't work automatically...I made a temporary prescription by designating each and every one.
I wish it was automatic...

huangapple
  • 本文由 发表于 2023年6月29日 09:00:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76577504.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定