圆角未应用于
内的所有角落?

huangapple go评论71阅读模式
英文:

Rounded corners not applying to all corners within div?

问题

对于某种原因,border-radius 不适用于 div 的所有角落(屏幕截图中的灰色部分)。我是否做错了什么?

另外,如果您注意到我的页眉最右边没有覆盖 - 我不知道这是否与 Chrome 有关?(我将附上我的页眉 CSS,以防万一)。

关于圆角:

HTML:

<div class="header"></div>
<h1 class="title">创意检查器</h1>
<div class="row">
  <div class="col-12 col-md-10 offset-md-1">
    <div class="alert alert-success" style="display: none"></div>
    <div class="alert alert-danger" style="display: none"></div>
    <div class="row">
      <div class="col-md-12">
        <p class="text-center">
          1. 选择产品类型:
        </p>
      </div>
    </div>
    <div class="row mb-3">
      <div class="col-lg-4">
        <button type="button" id="btn-snapshot" class="btn btn-secondary col-lg-12">快照</button>
      </div>
      <div class="col-lg-4">
        <button type="button" id="btn-tmd" class="btn btn-secondary col-lg-12">TMD</button>
      </div>
      <div class="col-lg-4">
        <button type="button" id="btn-bpush" class="btn btn-secondary col-lg-12">行为推送</button>
      </div>
    </div>
    <div class="row">
      <div class="col-lg-12">
        <p class="text-center">
          2. 上传文件夹/图片:
        </p>
        <form action="server.php" class="dropzone" id="my-awesome-dropzone" onsubmit="onSubmit()">
          <!-- <select name="product-type" id="product_type">
                <option value="snapshot">
                  快照
                </option>
                <option value="TMD">
                  TMD
                </option>
                <option value="b-push">
                  行为推送
                </option>
              </select> -->
        </form>
      </div>
    </div>
  </div>
</div>

CSS:

.row {
  padding-top: 12px;
  padding-bottom: 15px;
  background-color: #F1F1F1;
  border-radius: 50px;
}

关于页眉问题:

.header {
  min-height: 100px;
  background-image: url('header_wallpaper.png');
  background-position: center;
  background-size: contain;
}

圆角未应用于<div>内的所有角落?

英文:

For some reason border-radius is not applying to all corners of the div (the grey in the screenshot). Is there something I'm doing wrong?

Also, if you notice the furthest right of my header isn't covered - I don't suppose this is an issue with Chrome? (I'll attach my CSS for the header too just in case).

For Rounded Corners:

HTML:

&lt;div class=&quot;header&quot;&gt;&lt;/div&gt;
&lt;h1 class=&quot;title&quot;&gt;Creative Checker&lt;/h1&gt;
&lt;div class=&quot;row&quot;&gt;
&lt;div class=&quot;col-12 col-md-10 offset-md-1&quot;&gt;
&lt;div class=&quot;alert alert-success&quot; style=&quot;display: none&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;alert alert-danger&quot; style=&quot;display: none&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;row&quot;&gt;
&lt;div class=&quot;col-md-12&quot;&gt;
&lt;p class=&quot;text-center&quot;&gt;
1. Select product type:
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;row mb-3&quot;&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;button type=&quot;button&quot; id=&quot;btn-snapshot&quot; class=&quot;btn btn-secondary col-lg-12&quot;&gt;Snapshot&lt;/button&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;button type=&quot;button&quot; id=&quot;btn-tmd&quot; class=&quot;btn btn-secondary col-lg-12&quot;&gt;TMD&lt;/button&gt;
&lt;/div&gt;
&lt;div class=&quot;col-lg-4&quot;&gt;
&lt;button type=&quot;button&quot; id=&quot;btn-bpush&quot; class=&quot;btn btn-secondary col-lg-12&quot;&gt;Behavioural Push&lt;/button&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;row&quot;&gt;
&lt;div class=&quot;col-lg-12&quot;&gt;
&lt;p class=&quot;text-center&quot;&gt;
2. Upload folder/images:
&lt;/p&gt;
&lt;form action=&quot;server.php&quot; class=&quot;dropzone&quot; id=&quot;my-awesome-dropzone&quot; onsubmit=&quot;onSubmit()&quot;&gt;
&lt;!-- &lt;select name=&quot;product-type&quot; id=&quot;product_type&quot;&gt;
&lt;option value=&quot;snapshot&quot;&gt;
Snapshot
&lt;/option&gt;
&lt;option value=&quot;TMD&quot;&gt;
TMD
&lt;/option&gt;
&lt;option value=&quot;b-push&quot;&gt;
Behavioural Push
&lt;/option&gt;
&lt;/select&gt; --&gt;
&lt;/form&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

CSS:

.row {
padding-top: 12px;
padding-bottom: 15px;
background-color: #F1F1F1;
border-radius: 50px;
}

For Header Issue:

.header {
min-height: 100px;
background-image: url(&#39;header_wallpaper.png&#39;);
background-position: center;
background-size: contain;
}

圆角未应用于<div>内的所有角落?

答案1

得分: 1

我正在查看你的代码,我也在CodePen上尝试过,border-radius属性正常工作,即使在你分享的照片中,它似乎也做到了应该做的事情。我注意到div的左侧离浏览器边框太近了,这就是为什么似乎没有应用到整个div的原因。

首先,我建议你重置CSS。因为浏览器本身具有默认应用于页面的属性,这可能会使事情变得奇怪,也许这就是让你的div看起来像那样的原因。
要做到这一点,在你的CSS文件的开头添加以下代码:

*{
margin: 0;
padding: 0;
}

你还可以在重置CSS中添加像colorfont-family这样的东西,以应用于整个页面。

这应该解决div和标题的问题,如果不行,尝试添加类似这样的内容:.row{ margin: 1px;}.header{width:100%;}

英文:

I'm looking at your code and I also had tried it on codepen and the border-radius attribute it's working fine, even in the photo you shared it's seems like it's doing what it should do. I notice that the left side of the div it's too near to the borer of the browser and that's why it's seems to not being applied to all the div.

First of all, I recommend you to reset the css. Because the browser itself has properties which applies to your pages by default and it could make things work weird and maybe that's what it's making your div to look like that.
To do that, at the begining of your css file do:

*{
margin: 0;
padding: 0;
}

You could also add things like color or font-family inside of the reset css to apply things to the whole of the page.

That should solve the problem with the div and the header, if it doesn't, try to add to .row{ margin: 1px;} or something like that and .header{width:100%;}.

huangapple
  • 本文由 发表于 2020年1月3日 23:07:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/59580900.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定