Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

What is the correct what to do a CSS sub class?

Posted on 2014-10-29
3
Medium Priority
?
141 Views
Last Modified: 2014-10-30
Please have a look at my CSS code.  I'm pretty sure I'm doing this incorrectly and would like guidance on how to correct my code?

I have a parent css class of "wrapper".  I wanted to create sub-classes of "wrapper" and I'm not sure I'm doing it correctly.  Can you have a look at my code and provide suggestions for improvements.

Thanks!

<html>
<head>
<title>CSS</title>
<style>
.wrapper {
	width:100%;
}

.wrapper .formwrapper {
	width: 50%;
	padding: 5px;
}

.wrapper .formwrapper .mytextbox {
	color: red;
	float: left;
	width: 50%;
}

.wrapper .formwrapper .mybutton {
	color: red;
	float: left;
	width: 40%;
}

.wrapper .message {
	color: green;
	padding: 5px;
}


</style>
</head>
<body>

<div class="wrapper">
	<div class="title">This is my title</div>
    <div class="formwrapper">
    	<div class="mytextbox"><input name="firstName" type="text" /></div>
        <div class="mybutton"><input name="Submit" type="button" /></div>
    </div>
    <div class="message">Click The Button!</div>
</div>

</body>
</html>

Open in new window

0
Comment
Question by:cdemott33
3 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 1000 total points
ID: 40411883
Nothing wrong with what you have - whats the problem?
0
 
LVL 15

Assisted Solution

by:Insoftservice
Insoftservice earned 1000 total points
ID: 40414048
I hope you have issue with the alignment .
If yes
Please try below code

You had missed to use

clear:both;


<html>
<head>
<title></title>
<style>
.wrapper {
	width:100%;
}

.wrapper .formwrapper {
	width: 50%;
	padding: 5px;
}

.wrapper .formwrapper .mytextbox {
	color: red;
	float: left;
	width: 30%;
}

.wrapper .formwrapper .mybutton {
	color: red;
	float: right;
	width: 70%;
}

.wrapper .message {
	color: green;
	padding: 5px;
}
.clearboth{
clear:both;
}


</style>
</head>
<body>

<div class="wrapper">
	<div class="title">This is my title</div>
    <div class="formwrapper">
    	<div class="mytextbox"><input name="firstName" type="text" value="" /></div>
        <div class="mybutton"><input name="Submit" type="button"  value="Submit" /></div>
    </div>
	<div class='clearboth'></div>
    <div class="message">Click The Button!</div>
</div>

</body>
</html>
                                  

Open in new window

0
 

Author Comment

by:cdemott33
ID: 40414099
I just wanted to make sure I was doing it correctly.  Thanks for confirming.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question