Not able to split the div for rows and columns - html

creating this application in MVC5 with bootstrap....
I have added div :
<div class="divFullWidth" style="margin:10px 0px 0px -15px; height:150px;background-color:grey;">
<div class="wireframe_div">
<div class="Row">
<div class="Cell">
#Html.Label("Ext :")
</div>
</div>
<div class="Row">
<div class="Cell">
#Html.TextBox("txt_Ext", null, new { #class = "form-control" })
</div>
</div>
</div>
</div>
CSS :
.wireframe_div {
border: 1px solid black;
background-color: darkgrey;
padding: 15px 20px 25px 20px;
.Cell
{
display: table-cell;
padding-left: 5px;
padding-right: 5px;
}
.Row
{
display: table-row;
}
.divFullWidth {
float: left;
width: 100%;
}
But am not able split the div exactly like in screen shot.
Can any one help on this. Am very new to web tech.

<div style="width: 100%; height: 150px;">
<div style=" width: 100%; height: 30%;">
Ext <input type="text" style="width: 35%;"/>
Area <input type="text" style="width: 10%;"/>
</div>
<div style="width: 50%; height: 70%; float: left; text-align: center;">
Activity Catagory <input type="text" style="width: 80%;"/>
</div>
<div style="width: 50%; height: 70%; float: right;">
<div style="width: 50%; height: 100%; float: right; text-align: center;">
Activity Date To<input type="text" style="width: 80%;"/>
</div>
<div style="width: 50%; height: 100%; float: left; text-align: center;">
Activity Date From <input type="text" style="width: 80%;"/>
</div>
</div>
</div>
also try bootstrap it makes life easy

Related

Unwanted space under img in div using mPDF

I am using mPDF to create a PDF from the following HTML-Code:
<div style="border: 5px solid black; height: 115px;">
<div style="width: 29%; height: 115px; float: left; background-color: red;">
<img src="testimage.png"
alt="Bild 1" style="height: 115px;">
</div>
<div style="width: 55%; float: left; padding-top: 60px; font-size: 18px; font-weight: bold;">
SOME TEXT
</div>
<div style="float: right; width: 16%; font-size: 18px; padding-top: 10px;">
<div style="float: left; width: 25px;">ANOTHER TEXT</div>
</div>
</div>
The outcome in the PDF is rather unsatisfying:
The outcome
I am dealing with this weird space below the image. I tried giving the image a blue and the div a red background and it is always red, so the div is too high. It just ignores every fixed height I give. I already read about using display: top but none of it worked. What exactly is the problem here? On a HTML-Page everything is just fine.
Try adding width:100%; height:100%; object-fit:cover; to the image. Hope it works for you.
<div style="border: 5px solid black; height: 115px;">
<div style="width: 29%; height: 115px; float: left; background-color: red;">
<img src="https://via.placeholder.com/150"
alt="Bild 1" style="width:100%;
height:100%;
object-fit:cover;">
</div>
<div style="width: 55%; float: left; padding-top: 60px; font-size: 18px; font-weight: bold;">
SOME TEXT
</div>
<div style="float: right; width: 16%; font-size: 18px; padding-top: 10px;">
<div style="float: left; width: 25px;">ANOTHER TEXT</div>
</div>
</div>

image not displaying for checkbox (css)

I'm trying to use images as checkboxes in a grid layout, but the images won't show and I'm at a loss. Here is the relevant css and html. I have double checked the image address as this has been an issue in many other posts here, but it is stored at the address being accessed.
Any help is appreciated.
body{
width: 100vw;
height: 100vh;
margin-left: auto;
margin-right: auto;
}
.container {
width: 100%;
height: 100%;
margin: 0;
}
.jumbotron {
width: 100%;
float: left;
}
.four {
width: 32vw;
float: left;
margin-left: 2%;
/*background-color: #95a5a6;*/
}
.row {
width: 100vw;
height: 20vh;
clear: both;
padding: 0px;
margin: 0px;
}
.buttonLabel {
cursor: pointer;
}
.button input[type="checkbox"] {
display: none;
}
.button input[type="checkbox"] + label {
width: 32vw;
height: 20vh;
display: inline-block;
}
#accomLabel {
background: url('../img/shelter.png') no-repeat;
}
<div class="container">
<div class="row jumbotron heading">
<h1 style="text-align: center;">foo</h1>
<h3 style="text-align: center;">bar</h3>
</div>
<form method="post" id="services_form">
<div class="row">
<div class="four">
<div class="button">
<input type="checkbox" id="accomButton"></input>
<label class="buttonLabel" for="accomButton" id="accomLabel"></label>
</div>
</div>
<div class="four">
<div class="button">
<input type="checkbox" id="foodButton"></input>
<label class="buttonLabel" for="foodButton" id="foodLabel"></label>
</div>
</div>
<div class="four">
<div class="button">
<input type="checkbox" id="medicalButton"> </input>
<label class="buttonLabel" for="medicalButton" id="medicalLabel"></label>
</div>
</div>
</div>
</form>
</div>
Seems fine, although you don't need input closing tags (</input>). Here's a demo with placehold.it image:
body {
width: 100vw;
height: 100vh;
margin-left: auto;
margin-right: auto;
}
.container {
width: 100%;
height: 100%;
margin: 0;
}
.jumbotron {
width: 100%;
float: left;
}
.four {
width: 32vw;
float: left;
margin-left: 2%;
/*background-color: #95a5a6;*/
}
.row {
width: 100vw;
height: 20vh;
clear: both;
padding: 0px;
margin: 0px;
}
.buttonLabel {
cursor: pointer;
}
.button input[type="checkbox"] {
display: none;
}
.button input[type="checkbox"] + label {
width: 32vw;
height: 20vh;
display: inline-block;
}
#accomLabel {
background: url('http://placehold.it/54x54') no-repeat;
}
<div class="container">
<div class="row jumbotron heading">
<h1 style="text-align: center;">foo</h1>
<h3 style="text-align: center;">bar</h3>
</div>
<form method="post" id="services_form">
<div class="row">
<div class="four">
<div class="button">
<input type="checkbox" id="accomButton">
<label class="buttonLabel" for="accomButton" id="accomLabel"></label>
</div>
</div>
<div class="four">
<div class="button">
<input type="checkbox" id="foodButton">
<label class="buttonLabel" for="foodButton" id="foodLabel"></label>
</div>
</div>
<div class="four">
<div class="button">
<input type="checkbox" id="medicalButton">
<label class="buttonLabel" for="medicalButton" id="medicalLabel"></label>
</div>
</div>
</div>
</form>
</div>

DIV flow and border issue

What's wrong with the code. The border is faulty.
<div id="contents" style="width: 50%; height: auto; margin: 0 auto; left: 50%; border: 2px solid #73AD21;">
<div id="USER" style="margin: 5px">
<p style="width: 50%; text-align:left; padding-left: 1%; float: right; font-size: large"> user :</p>
<input id="txt_ID" type="text" style="width: 45%; float: left"/>
</div>
<div id="PASS" style="margin: 5px">
<p style="width: 50%; text-align:left; padding-left: 1%; float: right; font-size: large">pass :</p>
<input id="txt_Password" type="text" style="width: 45%; float: left"/>
</div>
</div>
You are using floats in the inner divs so the parent has no height. Just set float: left; to the contents div and you see your problem.
<div id="contents" style="width: 50%; height: auto; margin: 0 auto; float: left; left: 50%; border: 2px solid #73AD21;">
<div id="USER" style="margin: 5px">
<p style="width: 50%; text-align:left; padding-left: 1%; float: right; font-size: large"> user :</p>
<input id="txt_ID" type="text" style="width: 45%; float: left"/>
</div>
<div id="PASS" style="margin: 5px">
<p style="width: 50%; text-align:left; padding-left: 1%; float: right; font-size: large">pass :</p>
<input id="txt_Password" type="text" style="width: 45%; float: left"/>
</div>
</div>
You should probably not use inline-css but rather have a external css-file and use clearfix to clear floats on the contents div instead.
You using float elements so add clear: both before main div end
<div id="contents" style="width: 50%; height: auto; margin: 0 auto; left: 50%; border: 2px solid #73AD21;">
<div id="USER" style="margin: 5px">
<p style="width: 50%; text-align:left; padding-left: 1%; float: right; font-size: large"> user :</p>
<input id="txt_ID" type="text" style="width: 45%; float: left"/>
</div>
<div id="PASS" style="margin: 5px">
<p style="width: 50%; text-align:left; padding-left: 1%; float: right; font-size: large">pass :</p>
<input id="txt_Password" type="text" style="width: 45%; float: left"/>
</div>
<div style="clear: both"></div>
</div>
You have to clear floats.
Add following css
#contents:after {
content: '';
display: table;
clear:both;
}
You can apply #contents { float: left} or use clear float trick for parent to take inner element height:
#contents {
width: 50%;
height: auto;
margin: 0 auto;
left: 50%;
border: 2px solid #73AD21;
}
#contents:after {
content: '';
display: block;
clear: both;
}
#contents > div {
margin: 5px;
}
#contents p {
width: 50%;
text-align: left;
padding-left: 1%;
float: right;
font-size: large;
}
#contents input {
width: 45%;
float: left
}
<div id="contents">
<div id="USER">
<p>user :</p>
<input id="txt_ID" type="text" />
</div>
<div id="PASS">
<p>pass :</p>
<input id="txt_Password" type="text" />
</div>
</div>
It's because you're using float - this takes the element out of the normal flow, because everything is floated, the outer div has no height.
Use display: inline-block instead:
<div id="contents" style="width: 50%; height: auto; margin: 0 auto; left: 50%; border: 2px solid #73AD21;">
<div id="USER" style="margin: 5px">
<p style="width: 50%; text-align:left; padding-left: 1%; font-size: large; display: inline-block;"> user :</p>
<input id="txt_ID" type="text" style="width: 45%; display: inline-block;"/>
</div>
<div id="PASS" style="margin: 5px">
<p style="width: 50%; text-align:left; padding-left: 1%; font-size: large; display: inline-block;">pass :</p>
<input id="txt_Password" type="text" style="width: 45%; display: inline-block;"/>
</div>
</div>
link to fiddle
Your parent container is being collapsed by its floated children. I recommend using a clearfix class:
.cf:before,
.cf:after {
content: " "; /* 1 */
display: table; /* 2 */
}
.cf:after {
clear: both;
}
/**
* For IE 6/7 only
* Include this rule to trigger hasLayout and contain floats.
*/
.cf {
*zoom: 1;
}
<div class="cf" id="contents" style="width: 50%; height: auto; margin: 0 auto; left: 50%; border: 2px solid #73AD21;">
<div id="USER" style="margin: 5px">
<p style="width: 50%; text-align:left; padding-left: 1%; float: right; font-size: large"> user :</p>
<input id="txt_ID" type="text" style="width: 45%; float: left"/>
</div>
<div id="PASS" style="margin: 5px">
<p style="width: 50%; text-align:left; padding-left: 1%; float: right; font-size: large">pass :</p>
<input id="txt_Password" type="text" style="width: 45%; float: left"/>
</div>
</div>
Clearfix source: http://nicolasgallagher.com/micro-clearfix-hack/
Info on clearfix: What is a clearfix?

word-break css not aligned accordingly

Is there a way that i can make the word align properly? I tried to add word-break and word-wrap property in but it didn't make any different.
<div class="transreview" style="float: right; background-color: #e0e0e0; word-wrap: break-word; border-radius: 5px; padding: 10 20 10 20px;">
<div class="transreview-item" style="float: right; clear: both; width: 100%; margin-bottom: 10px;">
<label class="transreview-label" style="clear: both; width: 79%; text-align: right;"><b>Subtotal</b></label>
<div class="review-label" style="float: right; text-align: right; height: 20px; width: 120px; padding: 5 5 5 5px">S$42.50</div>
</div>
<div class="transreview-item" style="float: right; clear: both; width: 100%; margin-bottom: 10px;">
<label class="transreview-label" style="clear: both; width: 79%; text-align: right;"><b>Total Shipping</b></label>
<div class="review-label" style="float: right; text-align: right; height: 20px; width: 120px; padding: 5 5 5 5px">S$42.50</div>
</div>
</div>
Turn it into a table. I made a Fiddle. Just tweak the CSS and you should get the same result. But don't add CSS inline!
HTML
<table>
<tbody>
<tr>
<td>
Subtotal
</td>
<td>
<label>
S$42.50
</label>
</td>
</tr>
<tr>
<td>
Total Shipping
</td>
<td>
<label>
S$42.50
</label>
</td>
</tr>
<tr>
<td>
Tax
</td>
<td>
<label>
S$42.50
</label>
</td>
</tr>
<tr>
<td>
Discount
</td>
<td>
<label>
S$42.50
</label>
</td>
</tr>
<tr>
<td>
Total (including tax, if applicable)
</td>
<td>
<label>
S$42.50
</label>
</td>
</tr>
</tbody>
</table>
CSS
table{
background-color: #E0E0E0;
border-radius: 5px;
padding: 4px 0;
}
td label{
background-color: #FFF;
border-radius: 5px;
padding: 4px 4px 4px 20px;
}
td{
padding: 4px;
}
You have to put the fixed width for both the Parent container and the label. Please check http://jsfiddle.net/fanafazil/rcye5m36.
<div class="transreview" style="float: right; background-color: #e0e0e0; word-wrap: break-word; border-radius: 5px; padding: 10 20 10 20px; width: 210px;">
<div class="transreview-item" style="float: right; clear: both; width: 100%; margin-bottom: 10px;">
<div style="float: left;width:100px;padding-right: 5px;">
<label class="transreview-label" style="clear: both; width: 79%; text-align: right;"><b>Sub Total</b></label>
</div>
<div class="review-label" style="float: right; text-align: right; height: 20px; width: 90px; padding: 5 5 5 5px; background-color:#FFFFFF;">S$42.50</div>
</div>
<div class="transreview-item" style="float: right; clear: both; width: 100%; margin-bottom: 10px;">
<div style="float: left;width:100px;padding-right: 5px;">
<label class="transreview-label" style="clear: both; width: 79%; text-align: right;"><b>Total Shipping</b></label>
</div>
<div class="review-label" style="float: right; text-align: right; height: 20px; width: 90px; padding: 5 5 5 5px; background-color:#FFFFFF;">S$42.50</div>
</div>
<div class="transreview-item" style="float: right; clear: both; width: 100%; margin-bottom: 10px;">
<div style="float: left;width:100px;padding-right: 5px;">
<label class="transreview-label" style="clear: both; width: 79%; text-align: right;"><b>Tax</b></label>
</div>
<div class="review-label" style="float: right; text-align: right; height: 20px; width: 90px; padding: 5 5 5 5px; background-color:#FFFFFF;">S$42.50</div>
</div>
<div class="transreview-item" style="float: right; clear: both; width: 100%; margin-bottom: 10px;">
<div style="float: left;width:100px;padding-right: 5px;">
<label class="transreview-label" style="clear: both; width: 79%; text-align: right;"><b>Discount</b></label>
</div>
<div class="review-label" style="float: right; text-align: right; height: 20px; width: 90px; padding: 5 5 5 5px; background-color:#FFFFFF;">S$42.50</div>
</div>
<div class="transreview-item" style="float: right; clear: both; width: 100%; margin-bottom: 10px;">
<div style="float: left;width:100px;padding-right: 5px;">
<label class="transreview-label" style="clear: both; width: 79%; text-align: right;"><b>Total Shipping(Including Tax and VAT)</b></label>
</div>
<div class="review-label" style="float: right; text-align: right; height: 20px; width: 90px; padding: 5 5 5 5px; background-color:#FFFFFF;">S$42.50</div>
</div>
</div>

How to change div style when it switches to another page in html?

From the below figure. I am changing the div(tab) styles based on the different page.
If the control is in page 1, I am displaying the tab with red color border.
Likewise,
If the control is in page 2, I am displaying the tab with red color border and filling the background of page 1 with other color.
Here, I need to use <HR> tag to connect these page1, page2 and page3.
My output should be like this..
Here is my code.
index.html
<html>
<head>
<style>
.outer{
margin: 0 10%;
padding: 50px 0;
border: 2px solid #666666;
}
.hidden-div
{
display:none;
}
</style>
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>
<script>
function showHide(divId) {
$("#"+divId).toggle();
}
</script>
</head>
<body>
<div id="hidethis" style="display:none">
<hr/>
<ons-row style="display: flex;">
<div style="border: 3px solid #C10000; width: 19%; border-radius: 7px; margin-left: 10%; text-align: center; line-height: 2.5;">
Page 1
</div>
<div style="width: 20%; margin-left: 10%; text-align: center; line-height: 2.5; color: #9A9A9A;">Page 2</div>
<div style="width: 20%; margin-left: 10%; text-align: center; line-height: 2.5; color: #9A9A9A;">Page 3</div>
</ons-row>
<hr/>
<div class="outer">
<div class="row" style="text-align: center;">
Page 1 Content
</div>
</div>
<br>
</div>
<div id="hidethis2" style="display:none">
<hr/>
<ons-row style="display: flex;">
<div style="border: 3px solid #666666; border-radius: 7px; background-color: #666666; width: 20%; margin-left: 10%; text-align: center; line-height: 2.5; color: #9A9A9A;">
Page 1
</div>
<div style="border: 3px solid #C10000; width: 19%; border-radius: 7px; margin-left: 10%; text-align: center; line-height: 2.5;">Page 2</div>
<div style="width: 20%; margin-left: 10%; text-align: center; line-height: 2.5; color: #9A9A9A;">Page 3</div>
</ons-row>
<hr/>
<div class="outer">
<div class="row" style="text-align: center;">
Page 2 Content
</div>
</div>
<br>
</div>
<div id="hidethis3" style="display:none">
<hr/>
<ons-row style="display: flex;">
<div style="border: 3px solid #6F08F2; border-radius: 7px; background-color: #6F08F2; width: 20%; margin-left: 10%; text-align: center; line-height: 2.5; color: #9A9A9A;">
Page 1
</div>
<div style="border: 3px solid #6F08F2; border-radius: 7px; background-color: #6F08F2; width: 20%; margin-left: 10%; text-align: center; line-height: 2.5; color: #9A9A9A;">Page 2</div>
<div style="border: 3px solid #C10000; width: 19%; border-radius: 7px; background-color: #C10000; margin-left: 10%; text-align: center; line-height: 2.5;">Page 3</div>
</ons-row>
<hr/>
<div class="outer">
<div class="row" style="text-align: center;">
Page 3 Content
</div>
</div>
<br>
</div>
<input type="button" onclick="showHide('hidethis')" value="First Page" />
<input type="button" onclick="showHide('hidethis2')" value="Second Page">
<input type="button" onclick="showHide('hidethis3')" value="Third Page">
</body>
</html>
First I would add a class on each Page like:
HTML
<div id="hidethis" class="hidden-div">...</div>
<div id="hidethis2" class="hidden-div">...</div>
<div id="hidethis3" class="hidden-div">...</div>
Then in your JS hide first all elements with class hidden-div and then make the div with the right ID appear again:
JS
function showHide(divId) {
$('.hidden-div').each( function() {
$(this).hide();
});
$("#"+divId).show();
}
Here is a Fiddle. (Perhaps you have to change the HTML-Markup a little bit).
If you want to show the Page with the ID hidethis by default add this CSS Code:
#hidethis {
display: block;
}
This works because ID Selectors are higher rated by CSS than Class Selectors.
For more information about Selectors read this article.
EDIT:
According to your comments I think you are looking for something like this.
HTML
Insert a new div where a line should be shown and remove the margin-left: 10% property on the following div's CSS.
<div class="line"></div>
<div style="border: 3px solid #C10000; width: 19%; border-radius: 7px; text-align: center; line-height: 2.5;">Page 2</div>
CSS
Set width: 10% because of previous margin-left: 10%. Feel free to play with the other values.
.line {
width: 10%;
height: 2px;
background: green;
margin-top: 25px;
}