两边固定中间自适应

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title>Document</title>
    8. <style>
    9. *{
    10. margin: 0;
    11. padding: 0;
    12. }
    13. .outer{
    14. min-width: 1000px;
    15. overflow: hidden;
    16. }
    17. .main{
    18. width: 100%;
    19. height: 500px;
    20. background-color: yellowgreen;
    21. float: left;
    22. }
    23. .left{
    24. width: 200px;
    25. height: 500px;
    26. background-color: yellow;
    27. float: left;
    28. margin-left: -100%;
    29. }
    30. .right{
    31. width: 200px;
    32. height: 500px;
    33. background-color: orange;
    34. float: left;
    35. margin-left: -200px;
    36. }
    37. .inner{
    38. padding: 0 200px;
    39. }
    40. </style>
    41. </head>
    42. <body>
    43. <div class="outer">
    44. <div class="main">
    45. <div class="inner">中间</div>
    46. </div>
    47. <div class="left">左边</div>
    48. <div class="right">右边</div>
    49. </div>
    50. </body>
    51. </html>