Solved

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

Posted on 2014-10-29
3
121 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

706 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

21 Experts available now in Live!

Get 1:1 Help Now