One of many HTML components that steadily comes into collision with CSS is the img
factor. As we discovered in Request Metrics’ Fixing Cumulative Format Shift Issues on DavidWalshBlog article, offering picture dimensions inside the picture
tag will assist to enhance your web site’s rating. However in a world the place responsive design is king, we’d like CSS and HTML to work collectively.
Most responsive design fashion changes are accomplished through max-width
values, however whenever you present a peak
worth to your picture, you will get a distorted picture. The purpose ought to all the time be a show pictures in relative dimensions. So how can we make sure the peak
attribute does not battle with max-width
values?
The reply is as straightforward as peak: auto
!
/* assuming any media question */ img { /* Make sure the picture does not go offscreen */ max-width: 500px; /* Make sure the picture peak is responsive no matter HTML attribute */ peak: auto; }
The dance to please customers and engines like google is all the time a enjoyable steadiness. CSS and HTML had been by no means meant to battle however in some circumstances they do. Use this code to optimize for each customers and engines like google!
CSS Gradients
With CSS border-radius, I confirmed you ways CSS can bridge the hole between design and improvement by including rounded corners to components. CSS gradients are one other step in that course. Now that CSS gradients are supported in Web Explorer 8+, Firefox, Safari, and Chrome…
JavaScript Copy to Clipboard
“Copy to clipboard” performance is one thing all of us use dozens of occasions day by day however the consumer facet API round it has all the time been missing; some older APIs and browser implementations required a scary “are you certain?”-style dialog earlier than the content material can be copied to clipboard — not nice for…
Picture Reflection with jQuery and MooTools
One refined element that may make an enormous distinction on any internet design is using picture reflections. Utilizing them too usually can grow to be obnoxious however utilizing reflections on massive, “masthead” pictures is a cultured enhancement. Sadly creating picture reflections inside your…