Yes? The law is not some absolute arbiter of morality and it does change across time and jurisdictions. It's really only an expression of consequences that may be enforced by a body of power.
In many situations an individual does not feel represented by a certain law and it's equally ok for them to choose to follow their own moral compass as it is for the people who put that law in place to attempt to enforce their ways.