<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: W. Kasiban</title>
    <description>The latest articles on DEV Community by W. Kasiban (@kasiban).</description>
    <link>https://dev.to/kasiban</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F467925%2F8178367b-5714-49f8-9912-5749d22c812b.jpeg</url>
      <title>DEV Community: W. Kasiban</title>
      <link>https://dev.to/kasiban</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kasiban"/>
    <language>en</language>
    <item>
      <title>Round Image with frames</title>
      <dc:creator>W. Kasiban</dc:creator>
      <pubDate>Thu, 17 Sep 2020 11:16:57 +0000</pubDate>
      <link>https://dev.to/kasiban/round-image-with-frames-40j6</link>
      <guid>https://dev.to/kasiban/round-image-with-frames-40j6</guid>
      <description>&lt;p&gt;A round image makes a picture look soft.&lt;/p&gt;

&lt;p&gt;We begin with adding code in html like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;img src="cat.jpg" alt="cat" class="roundImg"/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Round image
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwuncmmxcq8v2dnvd641o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwuncmmxcq8v2dnvd641o.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
If you want a round image without any frame around the picture, then it is easy. &lt;br&gt;
Use the following code in css.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.roundImg {
  border-radius: 50%;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;border-radius&lt;/code&gt; property defines the radius of the picture's corners. &lt;br&gt;
So, if you want to create a circle shape, use &lt;code&gt;border-radius: 50%&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Round Image with One Frame
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fz077ylgwd7znqo441n74.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fz077ylgwd7znqo441n74.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
add the size, style and color of &lt;code&gt;border&lt;/code&gt; in your code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.roundImg {
  border-radius: 50%;
  border: 5px solid #ff0000;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Round Image with Double Frames
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fvk91wxerug8yfou791an.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fvk91wxerug8yfou791an.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
The code is similar with the round image with one frame. &lt;br&gt;
Now add one more line to the size of &lt;code&gt;border&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.roundImg {
  border-radius: 50%;
  padding: 10px;
  border: 5px solid #ff000;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Round Image, Double Frames with different border color
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fycytcoh7xdo036nv9lmq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fycytcoh7xdo036nv9lmq.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Sometimes you want to play with color on the frame of picture, to do so add &lt;code&gt;background-color&lt;/code&gt; to your padding.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.roundImg {
  border-radius: 50%;
  padding: 10px;
  border: 5px solid #ff000;
  background-color: #ffa500;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Round Image with Double and Shadow
&lt;/h2&gt;

&lt;p&gt;You also can play with &lt;code&gt;box-shadow&lt;/code&gt; property to make another layer on the picture's frame. Because &lt;code&gt;border-radius&lt;/code&gt; is set, the box shadow will take on the same rounded corners as border-radius.&lt;br&gt;
Remember the syntax of &lt;code&gt;box-shadow&lt;/code&gt; like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;box-shadow: outset-x | offset-y | blur-radius | spread-radius | color;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is what a box-shadow declaration looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.roundImg {
  border-radius: 50%;
  padding: 10px;
  border: 5px solid #ffffff;
  background-color: #ffa500;
  box-shadow: 0 0 30px 30px #ffa500;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Round Image with Triple Frame using Outline
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5qaiorp8m3aeuso4q3ru.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5qaiorp8m3aeuso4q3ru.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
The outline property is a line that is drawn around the elements, outside the border. The outline property is not part of the box model, so it won't affect the position of the element itself or the element next to it.&lt;br&gt;
The syntax of outline is (the order of the value does not matter.):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;outline: color | style | width;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Outline does not respect &lt;code&gt;border-radius&lt;/code&gt;. The outline is always rectangular by default, so we have to adjust the outline line to be a circular shape by adding &lt;code&gt;-moz-outline-radius&lt;/code&gt; as below.&lt;br&gt;
(The property &lt;code&gt;-moz-outline-radius&lt;/code&gt; can be used with Firefox only. It does not work in other browsers.)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.roundImg {
  border-radius: 50%;
  padding: 10px;
  border: 5px solid #fff;
  background-color: #ffa500;
  outline: #ff0000 solid 8px;
  -moz-outline-radius: 50% 50% 50% 50%;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Round Image with Triple Frame
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fma7inueuh2cn14n89r4t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fma7inueuh2cn14n89r4t.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Another way to create a round image with a triple frame is by adding another html &lt;code&gt;div&lt;/code&gt; cover to the image.&lt;br&gt;
In html it is going to look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div&amp;gt;
    &amp;lt;img src="cat.jpg" alt="cat" class="roundImg"/&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then customize the &lt;code&gt;div&lt;/code&gt; to be the circular shape.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div {
  border-radius: 50%;
  background-color: #ff0000;
  height: 23rem;
  width: 23rem;
  margin: 2rem;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The challenge is that the size of image has to be a little bit smaller than size of the cover div and has to be exactly in the middle of the cover div.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.roundImg {
  border-radius: 50%;
  width: 20rem;
  height: 20rem;
  padding: 10px;
  border: 5px solid #fff;
  background-color: #ffa500;
  margin: 0.5rem;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And it is not like &lt;code&gt;outline&lt;/code&gt;. The cover div is part of the box model. Whatever change you make in them, it will effect the adjacent elements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Special Thanks
&lt;/h2&gt;

&lt;p&gt;This cat image is by &lt;a href="https://pixabay.com/users/skeeze-272447/?utm_source=link-attribution&amp;amp;utm_medium=referral&amp;amp;utm_campaign=image&amp;amp;utm_content=1041324" rel="noopener noreferrer"&gt;skeeze&lt;/a&gt; from &lt;a href="https://pixabay.com/?utm_source=link-attribution&amp;amp;utm_medium=referral&amp;amp;utm_campaign=image&amp;amp;utm_content=1041324" rel="noopener noreferrer"&gt;Pixabay&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>css</category>
    </item>
  </channel>
</rss>
