+
95
-

css如何设定容器固定的长宽比率?

css如何设定容器固定的长宽比率?

网友回复

+
15
-

三种方式

第一、height + padding-bottom

<!DOCTYPE html>
<html>

<head>
    <title>height + padding-bottom</title>
    <style type="text/css">
        .box{
          width: 50%;
          height: 0;
          padding-bottom: 30%;
          /*宽高比为5:3*/
          background: url(//repo.bfw.wiki/bfwrepo/image/5d6539385ad28.png);
          background-size: cover;
  ...

点击查看剩余70%

我知道答案,我要回答