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

如何移除网站侧边栏及主体内容区域的自带边框?

Fixing Double Borders Between Main Content & Sidebar with Custom CSS

Absolutely—Custom CSS is the perfect solution to get rid of those annoying double borders between your main content area and sidebar. Let’s break this down into actionable steps:

Step 1: Identify the right elements with browser dev tools

First, you need to pinpoint which containers are adding the borders. Here’s how:

  • Right-click anywhere on your main content or sidebar and select Inspect (or press F12/Ctrl+Shift+I on Windows, Cmd+Opt+I on Mac).
  • In the developer tools panel, hover over the HTML elements to find the main content wrapper (usually has a class like .main-content, .content-area, or .primary) and the sidebar/widget area wrapper (like .widget-area, .secondary, or .sidebar).
  • Look for CSS properties like border, border-left, border-right, or even outline on these elements—these are what’s causing the double border.

Step 2: Write the Custom CSS to remove borders

Once you have the correct class names, add this code to your site’s Custom CSS section (usually found in Appearance > Customize > Additional CSS in your WordPress dashboard, or equivalent in your site builder):

/* Remove border from main content area */
.main-content {
  border: none !important;
  /* If the border is only on one side, use this instead: */
  /* border-right: none !important; */
}

/* Remove border from sidebar/widget area */
.widget-area {
  border: none !important;
  /* If the border is only on one side, use this instead: */
  /* border-left: none !important; */
}

Edge cases to consider

If the above doesn’t work, check for these scenarios:

  • Outline instead of border: Some themes use outline instead of border—replace border: none with outline: none !important; in the code.
  • Pseudo-element borders: Borders might be added via ::before or ::after pseudo-elements. For example:
    .main-content::after {
      border: none !important;
    }
    
  • Parent container borders: The border might be coming from a parent wrapper (like .site-content). Inspect one level up in the HTML tree and target that class instead.

Pro tip: Avoid overusing !important

While !important works quickly, it’s better to use more specific CSS selectors if you can. For example, if your theme uses .site .main-content, use that instead of just .main-content to override the theme’s default styles without !important.

If you’re still struggling to find the exact selectors, share the class names you see in the developer tools, and I can help tweak the code further!

内容的提问来源于stack exchange,提问作者Bruce Murungi

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 06:29:01