user784756
user784756

Reputation: 2363

Edit the form css of a django form

so the submit button looks like this:

<input type="submit" id='register_submit' class= value="{% trans 'Submit' %}" /></div>

and normall I would use a class to specify what the button looks like, but this has its own class that I cannot touch. What can I do here to give it a new class so I can customize the button?

Upvotes: 0

Views: 1663

Answers (2)

Pat
Pat

Reputation: 25675

An option would be to override the existing rule with a specific rule. So, if your output HTML is:

<input type="submit" class="django-submit" />

You could wrap it to end up with:

<div class="my-button">
    <input type="submit" class="django-submit" />
</div>

And then use your .my-button class to create a more specific CSS rule:

.my-button .django-submit {
    padding: 5px;
    color: #fff;
    background: #f00;
}

The following demo shows how the specific rule will override the generic rule.

Upvotes: 3

Barry Kaye
Barry Kaye

Reputation: 7761

You could give the button a style attribute which will always take precedence over any class attribute.

Upvotes: 0

Related Questions