I have a Django Charfield form that I would like to change via CSS. I want to change it in 2 ways.
1. Width = 300 (solution below)
2. Submit button inline with the input field (no idea)
forms.py:
class SheetForm(forms.Form):
sheet_lookup = forms.CharField(max_length=30)
served in my index.html template:
{% extends "check/base.html" %}
{% block content %}
<div>
<form method="POST" class="post-form">
{% csrf_token %}
<h1>Scan Here:</h1>{{ form.as_p }}
<button type="submit" class="save btn btn-default">Scan</button>
</form>
</div>
{% endblock %}
my base.html:
{% load staticfiles %}
<html>
<head>
<title>Sheet Checker</title>
<link href="http://fonts.googleapis.com/css?family=Francois+One" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="{% static "css/main.css" %}">
</head>
<body>
<div>
<h1><a href="{% url 'index' %}">Sheet Check</a></h1>
</div>
<div>
{% block content %}
{% endblock %}
</div>
</body>
</html>
I have a forms.py that works:
class SheetForm(forms.Form):
sheet_lookup = forms.CharField(
max_length=30,
widget=forms.TextInput(attrs={'style':'width:300;'}))
But I don't think this is the correct way to affect the width change.
Also I am completely stuck on making the button inline with the input field
widget=forms.TextInput(attrs={'style':'width:300px;'})works for me. Note: "px"