How can I adjust DIV width to contents

前端 未结 5 1590
一向
一向 2021-01-31 14:59

I have a div element with style attached:

.mypost {
    border: 1px solid Peru;
    font-family: arial;
    margin: auto;
    min-width: 700px;
    width: 700px;         


        
5条回答
  •  再見小時候
    2021-01-31 15:16

    I'd like to add to the other answers this pretty new solution:

    If you don't want the element to become inline-block, you can do this:

    .parent{
      width: min-content;
    }
    

    The support is increasing fast, so when edge decides to implement it, it will be really great: http://caniuse.com/#search=intrinsic

提交回复
热议问题