You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

HTML中<video>标签左侧1px黑边框的去除方法咨询

Fixing the Mysterious 1px Left Black Border on HTML <video> Elements

Hey there! Let's tackle that annoying 1px left black border on your <video> tag—even when you haven't set any border or outline CSS properties. Here are the most common fixes to try:

  • Reset default browser styles for the video element
    Browsers often apply subtle default margins, paddings, or inline display behaviors that can create unexpected visual gaps or borders. Add this CSS to override those defaults:

    video {
      margin: 0;
      padding: 0;
      display: block; /* Eliminates inline-block whitespace gaps */
      border: none !important;
      outline: none !important;
      box-shadow: none !important;
    }
    
  • Ensure perfect width matching with the parent container
    Sometimes fractional pixel widths (from percentage-based layouts) can cause browsers to render a tiny 1px "border" as a rounding artifact. Force the video to fill its parent container exactly:

    video {
      width: 100%;
      height: auto;
      object-fit: cover; /* Adjust to match your layout needs—cover/fill/contain */
    }
    

    If you're using a flex or grid layout, double-check that the parent container doesn't have hidden padding or overflow that's pushing the video slightly off.

  • Check the video source itself
    Rarely, the issue might be in the video file itself—some encoding processes can leave a thin 1px black edge on one side. Try previewing the video in a media player to rule this out.

  • Override inherited styles from parent elements
    Even if you haven't set borders on the video, a parent container might have a border-left or padding-left that's bleeding through. Inspect the parent element in your browser's dev tools and adjust its styles if needed.

内容的提问来源于stack exchange,提问作者Paulius Vitkus

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 09:14:37