<?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: Sureshkannan M</title>
    <description>The latest articles on DEV Community by Sureshkannan M (@sureshkannan_m).</description>
    <link>https://dev.to/sureshkannan_m</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%2F198607%2F51093b8b-13c7-41e6-8450-dea40b9bb2b9.jpg</url>
      <title>DEV Community: Sureshkannan M</title>
      <link>https://dev.to/sureshkannan_m</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sureshkannan_m"/>
    <language>en</language>
    <item>
      <title>CSS tricks - Resolving Size and Background Challenges with CSS Properties</title>
      <dc:creator>Sureshkannan M</dc:creator>
      <pubDate>Wed, 19 Jul 2023 16:52:36 +0000</pubDate>
      <link>https://dev.to/sureshkannan_m/css-tricks-54pn</link>
      <guid>https://dev.to/sureshkannan_m/css-tricks-54pn</guid>
      <description>&lt;p&gt;As a frontend developer, one common issue we encounter is when clients provide logos with different sizes and backgrounds for placement on websites. This can lead to inconsistencies in appearance. An example of this issue is shown below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lHpiyN8b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p7lzf8atg2eks6jyfdyg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lHpiyN8b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p7lzf8atg2eks6jyfdyg.png" alt="Image with different size and background " width="800" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To address the problem of varying image sizes, we can utilize the following CSS property to ensure the logos fit properly within their containers while maintaining their aspect ratios:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="nx"&gt;img&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;contain&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;aspect&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;ratio&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By applying object-fit: contain;, the image size will adjust to fit within the container, and the aspect ratio will be preserved. This results in a more visually pleasing display:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XKxjeMy0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ugnlhipfbuyyxd2zdl5m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XKxjeMy0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ugnlhipfbuyyxd2zdl5m.png" alt="Image with fixed width" width="800" height="87"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, even with fixed image sizes, we may still encounter situations where the logo backgrounds do not blend well with the container. To address this, we can use the following CSS properties:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="nx"&gt;background&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;blend&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;soft&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;light&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="nx"&gt;mix&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;blend&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;darken&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By applying background-blend-mode: soft-light; and mix-blend-mode: darken;, we can blend the logo image with the background color, ensuring a harmonious appearance:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--obqY2ffB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9u2gdyipld28cz5mp2ua.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--obqY2ffB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9u2gdyipld28cz5mp2ua.png" alt="Logos with matching background and size" width="800" height="55"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's important to note that these CSS properties, &lt;code&gt;background-blend-mode&lt;/code&gt; and &lt;code&gt;mix-blend-mode&lt;/code&gt;, may not be suitable for all image types or use cases. You can experiment with different property values to achieve the desired results.&lt;/p&gt;

&lt;p&gt;By exploring the potential of these CSS properties, we can enhance the visual consistency of logos with various sizes and backgrounds on websites.&lt;br&gt;
&lt;a href="https://github.com/sureshkannanm/css-solution/tree/main/logo"&gt;Sample Repo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>web</category>
      <category>image</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
