• Hi
    I’m new to this and I’m just begining to grasp the basics in CSS and coding.

    I want to make a new “class” defining certain images that’s not to be ruled by the “main img” code in the style sheet. My main images has a border and I want some images to be clean without any borders. I’ve made a new class and called it img.clean defining no borders. The tag will then look like this <img src=”https://www…&#8221; alt=”name of picture” class=”clean” />. Now my problem is that this rules out the class=”centered” style and all “clean” images end up being aligned left as default.

    If this makes any sence at all… How can I have a new class and still make the picture centered?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi, a lesser known fact is that you can assign multiple classes to something, so you can for example do something like class=”centered clean” and it will work.

    If there are any conflicts in this, what you could also do is check the centered class rules which you can find looking like this in your stylesheet:

    .centered {
    [rules here]
    }

    and see which part makes the image centered. Then copy and paste those line(s) into your clean section like this

    .clean {
    [add it here]
    }

    Hope this helps

    Thread Starter riis

    (@riis)

    Ah! Thank you! It seems to work fine with the multiple class
    “centered clean”.

    Thaks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Making a new class for images’ is closed to new replies.