0

I want to make the form looks 1200px in width. However, when I set width in class .container or .form-group, or even in form tag, it won't work. Only when I set width in textarea tag will it work. What is the problem?

index.html

<!DOCTYPE html>
<html>
<head>
    <link href="style.css" rel="stylesheet">
</head>

<body>
<div class="container">
<form>
        <div class="form-group">
            <textarea class="status-box"></textarea>
        </div>
</form>
</div>
</body>

</html>

style.css

.container {
    width: 1200px;
    margin-top: 20px;
}
3
  • You do not have in css link type="text/css" Commented Apr 7, 2016 at 8:50
  • 4
    You only want the .container to be 1200px width? In that case your CSS works fine - jsfiddle.net/0h5pbaLs Commented Apr 7, 2016 at 8:50
  • @wolfgang1983 that isn't needed Commented Apr 7, 2016 at 8:51

6 Answers 6

3

Your container size is fine - but if you want your elements to fill the container, you'll need to set the width of them seperately.

E.g.

.container { width: 1200px; }

textarea, input { width: 100%; }
Sign up to request clarification or add additional context in comments.

Comments

0

If you want the textarea fill the 1200px, just add this line in your CSS code :

textarea {width: 100%;}

See it here

Comments

0

Also provide some height in CSS Class

.container {
    width: 1200px;
    margin-top: 20px;
min-height:10px // or Height:whatever the height you prefers
}

Comments

0

Just to make sure that the CSS knows where it's being applied, you should try this in your style file:

.container .form-group {
  width: 1200px;
  margin-top: 20px;
}

Or if you're tying to size your text area you need to use it's rows and cols attributes: http://www.w3schools.com/tags/tag_textarea.asp

1 Comment

You will use rows and cols if you need to size the textarea based on the font family and font size of the textarea, but cols is most of the time not that usefull. Using css and width is a better choice.
0

Please add "background-color: gray" to your container class. You will see the div width works. The width is for div, while it's not for the content in the div. So the right way is add width to textarea.

Comments

0

There isn't a problem. As you can see the width is already active tho it doesn't show since there is no identification. snippet here. If you change your css to look like the following you can see it for yourself.

.container {
    width: 1200px;
    margin-top: 20px;
    background-color:blue; <-- This will show the full width of your div in a color
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.