Solved

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

Posted on 2014-10-29
3
123 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 250 total points
ID: 40411883
Nothing wrong with what you have - whats the problem?
0
 
LVL 15

Assisted Solution

by:Insoftservice
Insoftservice earned 250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Send Mail Via SMTP Replacement/Rework 11 61
My dialog box isnt work, no box displays but text does 8 38
.php tree directory? 5 57
CSS z-index issue 3 22
This article discusses four methods for overlaying images in a container on a web page
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

867 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now