Bootstrap 5 的 rounded-circle 类不起作用

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

Bootstrap 5 rounded-circle class not working

问题

    <!-- language: lang-css -->

    @import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap');
    body {
        background: #f1f2fa;
        font-family: 'Poppins', sans-serif;
    }

    hr {
        border: 1.5px solid #0b5ed7
    }

    .crd {
        background: #f1f2fa;
        transition: all;
    }

    .crd:hover {
        background: #0b5ed7;
        color: #fff;
        transition: 0.5s;
    }

    .card img {
        margin: auto;
    }
英文:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

@import url(&#39;https://fonts.googleapis.com/css2?family=Poppins&amp;display=swap&#39;);
body {
	background: #f1f2fa;
	font-family: &#39;Poppins&#39;, sans-serif;
}

hr {
	border: 1.5px solid #0b5ed7
}

.crd {
	background: #f1f2fa;
	transition: all;
}

.crd:hover {
	background: #0b5ed7;
	color: #fff;
	transition: 0.5s;
}

.card img {
	margin: auto;
}

<!-- language: lang-html -->

&lt;!doctype html&gt;
&lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
    &lt;meta charset=&quot;utf-8&quot; /&gt;
&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&gt;

&lt;title&gt;Your awesome title: &lt;/title&gt;

&lt;meta name=&quot;description&quot; content=&quot;Write an awesome description for your new site here. It will appear in your document head meta (for Google search results) and in your feed.xml site description.&quot; /&gt;

&lt;link rel=&quot;stylesheet&quot; href=&quot;/_bridgetown/static/css/main.c7d4dd3f1984a290e9be.css&quot; /&gt;
&lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot;&gt;
&lt;link rel=&quot;stylesheet&quot; 
href=&quot;https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css&quot;&gt;
&lt;link rel=&quot;stylesheet&quot; 
href=&quot;https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css&quot;&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;./index.css&quot; /&gt;
&lt;script src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;/_bridgetown/static/js/main.96ffffaea92690057bfb.js&quot; defer&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
	&lt;!-- OUR CLIENTS SECTION START --&gt;
&lt;section class=&quot;bg-dark text-center&quot;&gt;
	&lt;div class=&quot;container&quot;&gt;
	  &lt;div class=&quot;row text-white py-5&quot;&gt;
		&lt;h2 class=&quot;display-6&quot;&gt;100&#39;s of Companies have Switched to Our Company&lt;/h2&gt;
		&lt;div class=&quot;col-12&quot;&gt;
		  &lt;div class=&quot;carousel slide&quot; data-bs-ride=&quot;carousel&quot;&gt;
			&lt;div class=&quot;carousel-inner&quot;&gt;
			  &lt;div class=&quot;carousel-item active&quot;&gt;
				&lt;div class=&quot;row&quot;&gt;
				  &lt;div class=&quot;col-lg-4&quot;&gt;
					&lt;div class=&quot;card bg-light text-dark&quot;&gt;
					  &lt;img src=&quot;./assets/favicon-Icon Only [G]_76x76.png&quot; class=&quot;img-fluid rounded-circle mt-4&quot; /&gt;
					  &lt;div class=&quot;card-body&quot;&gt;
						&lt;p class=&quot;lead text-center text-muted mt-4&quot;&gt;John Doe&lt;/p&gt;
						&lt;p&gt;Sit occaecat amet aute duis occaecat irure ea. Nostrud minim aliqua esse amet. Culpa laborum voluptate culpa excepteur in in ullamco velit aliqua.
  
						&lt;/p&gt;
						&lt;p class=&quot;text-warning&quot;&gt;
						  &lt;i class=&quot;fa-solid fa-star fa-1x&quot;&gt;&lt;/i&gt;
						  &lt;i class=&quot;fa-solid fa-star fa-1x&quot;&gt;&lt;/i&gt;
						  &lt;i class=&quot;fa-solid fa-star fa-1x&quot;&gt;&lt;/i&gt;
						  &lt;i class=&quot;fa-solid fa-star fa-1x&quot;&gt;&lt;/i&gt;
						  &lt;i class=&quot;fa-solid fa-star fa-1x&quot;&gt;&lt;/i&gt;
  
						&lt;/p&gt;
					  &lt;/div&gt;
					&lt;/div&gt;
				  &lt;/div&gt;
				&lt;/div&gt;
			  &lt;/div&gt;
			&lt;/div&gt;
		  &lt;/div&gt;
		&lt;/div&gt;
	  &lt;/div&gt;
	&lt;/div&gt;
  &lt;/section&gt;
  &lt;!-- OUR CLIENTS SECTION CLOSE --&gt;
  &lt;/body&gt;
&lt;/html&gt;

<!-- end snippet -->

I am using Bootstrap 5 to make a website and I am currently using it to make a course that displays cards of different people's reviews, but I am trying to use the rounded-circle class on an image but it isn't working, no circle appears around the image. There is supposed to be a rounded circle around the image but for some reason it's not appearing.

This is what it currently looks like Bootstrap 5 的 rounded-circle 类不起作用

This is what it's supposed to look like Bootstrap 5 的 rounded-circle 类不起作用

Code

Index.html

&lt;!doctype html&gt;
&lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
    &lt;meta charset=&quot;utf-8&quot; /&gt;
&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&gt;

&lt;title&gt;Your awesome title: &lt;/title&gt;

&lt;meta name=&quot;description&quot; content=&quot;Write an awesome description for your new site here. It will appear in your document head meta (for Google search results) and in your feed.xml site description.&quot; /&gt;

&lt;link rel=&quot;stylesheet&quot; href=&quot;/_bridgetown/static/css/main.c7d4dd3f1984a290e9be.css&quot; /&gt;
&lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot;&gt;
&lt;link rel=&quot;stylesheet&quot; 
href=&quot;https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css&quot;&gt;
&lt;link rel=&quot;stylesheet&quot; 
href=&quot;https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css&quot;&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;./index.css&quot; /&gt;
&lt;script src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;/_bridgetown/static/js/main.96ffffaea92690057bfb.js&quot; defer&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
	&lt;!-- OUR CLIENTS SECTION START --&gt;
&lt;section class=&quot;bg-dark text-center&quot;&gt;
	&lt;div class=&quot;container&quot;&gt;
	  &lt;div class=&quot;row text-white py-5&quot;&gt;
		&lt;h2 class=&quot;display-6&quot;&gt;100&#39;s of Companies have Switched to Our Company&lt;/h2&gt;
		&lt;div class=&quot;col-12&quot;&gt;
		  &lt;div class=&quot;carousel slide&quot; data-bs-ride=&quot;carousel&quot;&gt;
			&lt;div class=&quot;carousel-inner&quot;&gt;
			  &lt;div class=&quot;carousel-item active&quot;&gt;
				&lt;div class=&quot;row&quot;&gt;
				  &lt;div class=&quot;col-lg-4&quot;&gt;
					&lt;div class=&quot;card bg-light text-dark&quot;&gt;
					  &lt;img src=&quot;./assets/favicon-Icon Only [G]_76x76.png&quot; class=&quot;img-fluid rounded-circle mt-4&quot; /&gt;
					  &lt;div class=&quot;card-body&quot;&gt;
						&lt;p class=&quot;lead text-center text-muted mt-4&quot;&gt;John Doe&lt;/p&gt;
						&lt;p&gt;Sit occaecat amet aute duis occaecat irure ea. Nostrud minim aliqua esse amet. Culpa laborum voluptate culpa excepteur in in ullamco velit aliqua.
  
						&lt;/p&gt;
						&lt;p class=&quot;text-warning&quot;&gt;
						  &lt;i class=&quot;fa-solid fa-star fa-1x&quot;&gt;&lt;/i&gt;
						  &lt;i class=&quot;fa-solid fa-star fa-1x&quot;&gt;&lt;/i&gt;
						  &lt;i class=&quot;fa-solid fa-star fa-1x&quot;&gt;&lt;/i&gt;
						  &lt;i class=&quot;fa-solid fa-star fa-1x&quot;&gt;&lt;/i&gt;
						  &lt;i class=&quot;fa-solid fa-star fa-1x&quot;&gt;&lt;/i&gt;
  
						&lt;/p&gt;
					  &lt;/div&gt;
					&lt;/div&gt;
				  &lt;/div&gt;
				&lt;/div&gt;
			  &lt;/div&gt;
			&lt;/div&gt;
		  &lt;/div&gt;
		&lt;/div&gt;
	  &lt;/div&gt;
	&lt;/div&gt;
  &lt;/section&gt;
  &lt;!-- OUR CLIENTS SECTION CLOSE --&gt;
  &lt;/body&gt;
&lt;/html&gt;

Index.css

@import url(&#39;https://fonts.googleapis.com/css2?family=Poppins&amp;display=swap&#39;);
body {
	background: #f1f2fa;
	font-family: &#39;Poppins&#39;, sans-serif;
}

hr {
	border: 1.5px solid #0b5ed7
}

.crd {
	background: #f1f2fa;
	transition: all;
}

.crd:hover {
	background: #0b5ed7;
	color: #fff;
	transition: 0.5s;
}

.card img {
	margin: auto;
}

答案1

得分: 1

图像已经被圆角化。您的结果与预期结果的区别在于示例照片的颜色不同,而您的图像与其周围的区域一样是白色。

在以下示例中,我只需将三行代码添加到您的CSS中,以使圆角图像更加明显。

.card img {
    width: 76px;
    aspect-ratio: 1;
    background-color: silver;
}

希望这对您有所帮助。

英文:

The image is rounded. The difference between your result and the intended result is that the example photo has a different color whereas your image is the same white color as the area around it.

In the following example, I only added three lines to your CSS to make the rounded image more apparent.

.card img {
    width: 76px;
    aspect-ratio: 1;
    background-color: silver;
}

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

body {
    background: #f1f2fa;
    font-family: &#39;Poppins&#39;, sans-serif;
}

hr {
    border: 1.5px solid #0b5ed7
}

.crd {
    background: #f1f2fa;
    transition: all;
}

.crd:hover {
    background: #0b5ed7;
    color: #fff;
    transition: 0.5s;
}

.card img {
    margin: auto;
    width: 76px;
    aspect-ratio: 1;
    background-color: silver;
}

<!-- language: lang-html -->

&lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot;&gt;
    &lt;!-- OUR CLIENTS SECTION START --&gt;
&lt;section class=&quot;bg-dark text-center&quot;&gt;
    &lt;div class=&quot;container&quot;&gt;
      &lt;div class=&quot;row text-white py-5&quot;&gt;
        &lt;h2 class=&quot;display-6&quot;&gt;100&#39;s of Companies have Switched to Our Company&lt;/h2&gt;
        &lt;div class=&quot;col-12&quot;&gt;
          &lt;div class=&quot;carousel slide&quot; data-bs-ride=&quot;carousel&quot;&gt;
            &lt;div class=&quot;carousel-inner&quot;&gt;
              &lt;div class=&quot;carousel-item active&quot;&gt;
                &lt;div class=&quot;row&quot;&gt;
                  &lt;div class=&quot;col-lg-4&quot;&gt;
                    &lt;div class=&quot;card bg-light text-dark&quot;&gt;
                      &lt;img src=&quot;./assets/favicon-Icon Only [G]_76x76.png&quot; class=&quot;img-fluid rounded-circle mt-4&quot; /&gt;
                      &lt;div class=&quot;card-body&quot;&gt;
                        &lt;p class=&quot;lead text-center text-muted mt-4&quot;&gt;John Doe&lt;/p&gt;
                        &lt;p&gt;Sit occaecat amet aute duis occaecat irure ea. Nostrud minim aliqua esse amet. Culpa laborum voluptate culpa excepteur in in ullamco velit aliqua.
  
                        &lt;/p&gt;
                        &lt;p class=&quot;text-warning&quot;&gt;
                          &lt;i class=&quot;fa-solid fa-star fa-1x&quot;&gt;&lt;/i&gt;
                          &lt;i class=&quot;fa-solid fa-star fa-1x&quot;&gt;&lt;/i&gt;
                          &lt;i class=&quot;fa-solid fa-star fa-1x&quot;&gt;&lt;/i&gt;
                          &lt;i class=&quot;fa-solid fa-star fa-1x&quot;&gt;&lt;/i&gt;
                          &lt;i class=&quot;fa-solid fa-star fa-1x&quot;&gt;&lt;/i&gt;
  
                        &lt;/p&gt;
                      &lt;/div&gt;
                    &lt;/div&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/section&gt;
  &lt;!-- OUR CLIENTS SECTION CLOSE --&gt;

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年7月11日 02:55:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76656565.html
匿名

发表评论

匿名网友

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

确定