简体   繁体   English

如何在屏幕CSS中缩放适合高度固定大小的孩子,仅允许使用JavaScript

[英]How to scale fit height fixed size child in the screen css only javascript allowed

I have two child with fixed size: 我有两个固定大小的孩子:

<div class="parent">
  <div class="static_child">
  </div>
  <div class="static_child">
  </div>
</div>

.parent {
  border: 1px solid black;
  display: flex;
  flex-direction: column;
}

.static_child {
  border: 1px solid red;
  width: 600px;
  height: 200px;
}

I need to make this children responsive so they fit/fill the screen. 我需要让这些孩子反应灵敏,使他们适合/填满屏幕。

I can't change their fixed size. 我无法更改其固定大小。

I need to have both child to appear on the screen, by scaling down. 通过缩小,我需要让两个孩子都出现在屏幕上。 They should respond to bigger screen by growing appropriately. 他们应该通过适当增长来应对更大的屏幕。

http://codepen.io/eguneys/pen/zGbqqB http://codepen.io/eguneys/pen/zGbqqB

I'm not sure if I'm reading your question right, but you could change the width: 600px to width: 100% . 我不确定我是否在正确阅读您的问题,但是您可以将width: 600px更改为width: 100% This way the width of your blocks will stretch to accommodate various screen sizes. 这样,您的块的宽度将可以扩展以适应各种屏幕尺寸。 The same does not seem to work for the height though. 但是,对于高处来说,这似乎并不起作用。 Hope this helped. 希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM