问题描述:

I'm a little stuck, so I hope you can help me.

I have a page where I want some buttons to be images, but, while I want them in a line (inside de cell of a table), when using <form> they get one on top of other.

That's why I want to use the <a> tag.

Here's the form I want to submit:

<form action="{% url send_img_data %}" method="POST">{% csrf_token %}

<input type="hidden" name="param" value="{{ data_img.id }}">

<input type="image" title="{{ data_img.name }}" src="{{ STATIC_URL }}img/{{ data_img }}.png" alt="Submit Form" name="image">

</form>

Any idea on how can I do the same but with an <a> tag?

PS: In the back I'm using Django

网友答案:

Use CSS to re-arrange your input tags. Add:

input {
    display: inline-block;
}

Don't use a tag to hold form data, data won't get submitted on form submission. Only input tags can hold form data.

网友答案:

You should use css property as following:

a
{
   display:inline-block; 
}

And let me know is it work for you.

P.S. If you are using <a> tag as button you should consider to submit your form using javascript and ajax call. Because your <a> button will not sumbit form. So consider about this.

网友答案:

Another option is defin the image of the button on the CSS

.buttonStyle {
    border: none;
    background: url('../../../img/image.png');
    height: 17px;
    width: 16px;
    font: 10px/14px Helvetica, Helvetica Neue, Arial;
    color: transparent;
    padding: 0 0 0 16px !important;
}

Template:

<input  id="submit" type="submit" class="buttonStyle"
                                    name="submit">
相关阅读:
Top