How to display two elements on the same line?

后端 未结 2 1988
醉梦人生
醉梦人生 2020-12-12 07:57

Here I want to display this slide show and the video inline. I\'ve tried thousand different examples but they couldn\'t solve my problem. Any helpful suggestion will be an i

2条回答
  •  余生分开走
    2020-12-12 08:44

    Nowadays you can use flexboxes to put two elements side-by-side. CSS-tricks has a very thorough guide on the topic, so I won't bre you with the details.

    In your particular case, use something like:

    .slideshow {
      display: flex;
      justify-content: space-between;
      // no float and similar here
    }
    
    .slideshow > div {
      width: 50%;
    }
    

    You may need to prefix the flex and justify-content for better cross-browser support, and you may need to add flex: 1 for IE 10 support.

    You could also clean the code up a little. You don't want to use whitespace around the = sign in the attributes, and you don't need to specify the style attribute multiple times. One is enough, with semicolon-separated rules.

提交回复
热议问题