Skip to main content

Preview

Generated Code

HTML
<div class="video-embed" style="max-width: 100%">
  <div class="video-wrapper" style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: 8px; background: #000000; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15)">
    <iframe
      src="https://www.youtube.com/embed/dQw4w9WgXcQ"
      style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0;"
      allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
      allowfullscreen
    ></iframe>
  </div>
</div>
CSS
.video-embed {
  max-width: 100%;
}

.video-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #000000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.video-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
React Component
const VideoEmbed = () => {
  return (
    <div className="video-embed" style={{ maxWidth: '100%' }}>
      <div
        className="video-wrapper"
        style={{
          position: 'relative',
          paddingBottom: '56.25%',
          height: 0,
          overflow: 'hidden',
          borderRadius: 8,
          background: '#000000',
          boxShadow: '0 4px 20px rgba(0, 0, 0, 0.15)',
        }}
      >
        <iframe
          src="https://www.youtube.com/embed/dQw4w9WgXcQ"
          style={{
            position: 'absolute',
            top: 0,
            left: 0,
            width: '100%',
            height: '100%',
            border: 0,
          }}
          allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
          allowFullScreen
        />
      </div>
    </div>
  );
};

export default VideoEmbed;

Rate this tool