Solved

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

Posted on 2014-10-29
3
132 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Disabling a Faux Submit Button 4 41
Editing .asp website 5 32
Best explanation of following code css 11 40
In wordpress, how did they do that? 3 15
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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 how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

738 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