i'm trying to create a page structure, but i have a problem with position of div.
I have 2 div (purple) into a div parent (red). And after parent div, another div (green). I want to have the green div bottom the red one.
But the browser show me the purple div not into the red one (their parent), and so the green div is not under the red and purple divs, but only under the red one.
I make a snippet to show you:
div#form {
background: red;
}
div#search {
background: yellow;
}
div.accostati {
float: left;
margin: 5px;
background: purple;
}
div#test {
background: green;
}
<div id="form">
<p> CERCA GOMME </p>
<div id="label-search" class="accostati">
<p class="select">LABEL-FIELD:</p><br>
<p class="select">LABEL-FIELD:</p><br>
<p class="select">LABEL-FIELD:</p><br>
<p class="select">LABEL-FIELD:</p><br>
</div>
<div class="accostati">
<form name="cercaGommeCasa" action="gommeincasa.php" method="POST">
<select name="marca">
<option value="1">1</option>
</select><br>
<select name="modello">
<option value="2">2</option>
</select> <br>
<input type="submit" value="CERCA">
</form>
</div>
</div>
<div id="test">
riga1 <br>
riga2 <br>
riga3 <br>
</div>
Have you any idea how to show the purple div into the red one, in order to have green div under both purple and red divs...
Thank you!
Add overflow:auto to div#form:
div#form {
background: red;
overflow:auto;
}
div#form {
background: red;
overflow:auto;
}
div#search {
background: yellow;
}
div.accostati {
float: left;
margin: 5px;
background: purple;
}
div#test {
background: green;
}
<div id="form">
<p> CERCA GOMME </p>
<div id="label-search" class="accostati">
<p class="select">LABEL-FIELD:</p><br>
<p class="select">LABEL-FIELD:</p><br>
<p class="select">LABEL-FIELD:</p><br>
<p class="select">LABEL-FIELD:</p><br>
</div>
<div class="accostati">
<form name="cercaGommeCasa" action="gommeincasa.php" method="POST">
<select name="marca">
<option value="1">1</option>
</select><br>
<select name="modello">
<option value="2">2</option>
</select> <br>
<input type="submit" value="CERCA">
</form>
</div>
</div>
<div id="test">
riga1 <br>
riga2 <br>
riga3 <br>
</div>
You can use display: inline-block for both those divs
Like this
div#form {
background: red;
display: inline-block;
}
div.accostati {
display: inline-block;
margin: 5px;
background: purple;
}
div#form {
background: red;
display: inline-block;
}
div#search {
background: yellow;
}
div.accostati {
display: inline-block;
margin: 5px;
background: purple;
}
div#test {
background: green;
}
<div id="form">
<p> CERCA GOMME </p>
<div id="label-search" class="accostati">
<p class="select">LABEL-FIELD:</p><br>
<p class="select">LABEL-FIELD:</p><br>
<p class="select">LABEL-FIELD:</p><br>
<p class="select">LABEL-FIELD:</p><br>
</div>
<div class="accostati">
<form name="cercaGommeCasa" action="gommeincasa.php" method="POST">
<select name="marca">
<option value="1">1</option>
</select><br>
<select name="modello">
<option value="2">2</option>
</select> <br>
<input type="submit" value="CERCA">
</form>
</div>
</div>
<div id="test">
riga1 <br>
riga2 <br>
riga3 <br>
</div>
Related
So I added Two background in Homepage. One is Blue shade and another is an Image. I want to That Blue shade to see more that image. How can I do it.
HTML:
<div class="banner banner-4 banner-4-bg">
<div class="container">
<div class="row">
<div class="col-12">
<div class="banner-content">
<h1>The Easiest Way to Find Job</h1>
<p>Find Jobs, Employment & Career Opportunities</p>
<div class="banner-search">
<form action="#" class="search-form">
<input type="text" placeholder="Enter Keywords">
<select class="selectpicker" id="search-location">
<option value="" selected>Location</option>
<option value="california">California</option>
<option value="las-vegas">Las Vegas</option>
<option value="new-work">New Work</option>
<option value="carolina">Carolina</option>
<option value="chicago">Chicago</option>
<option value="silicon-vally">Silicon Vally</option>
<option value="washington">Washington DC</option>
<option value="neveda">Neveda</option>
</select>
<button class="button primary-bg"><i class="fas fa-search"></i>Search Job</button>
</form>
<div class="trending-key">
<span>Trending Keywords:</span>
designer
php
ios
Android
Accounting
Management
</div>
</div>
</div>
</div>
</div>
</div>
</div>
MY CSS:
.banner-4-bg {
background: url(../images/bg/banner_home.png) , url(../images/bg/banner-4-bg.jpg) no-repeat center;
background-size: cover;
}
.banner-4 .banner-content {
padding: 290px 0 210px;
text-align: center;
color: #ffffff;
}
What I have now :
And What I want:
Help me out Good people :)
There are different ways to do it:
Modify the image and make the same as displayed in the second one.
Make another div same width and height as image and {position: absolute} such that it overlaps the image then { background-color: 'some gray or black color', opacity: 0.5 } (adjust opacity and background-color accordingly). also, write all the displaying content on the banner in this div.
You can adjust the transparency of an image by using CSS opacity, where opacity is between 0.0 - 1.0 and the lower value, the more transparent, e.g.:
.banner-4-bg {
background: url(../images/bg/banner_home.png) , url(../images/bg/banner-4-bg.jpg) no-repeat center;
background-size: cover;
opacity: 0.5;
}
.banner-4 .banner-content {
padding: 290px 0 210px;
text-align: center;
color: #ffffff;
}
Here you go(view it in full screen mode):
I tried to get the images you shared and used it may the clarity is not clear. You may need to use the texts field as you want. As I mentioned in comments interchange the background:urls that should fix for you.
When using the multiple background images, images will be stacked upon each other and the first is the closest to the view.
.banner-4-bg {
background: url(https://i.postimg.cc/DyJRcGNB/Px3iz.png), url(https://i.postimg.cc/wTL0vQZ8/azHDz.jpg) no-repeat center;
background-size: cover;
}
.banner-4 .banner-content {
padding: 290px 0 210px;
text-align: center;
color: #ffffff;
}
<div class="banner-4-bg">
</div>
<div class="banner banner-4 banner-4-bg">
<div class="container">
<div class="row">
<div class="col-12">
<div class="banner-content">
<h1>The Easiest Way to Find Job</h1>
<p>Find Jobs, Employment & Career Opportunities</p>
<div class="banner-search">
<form action="#" class="search-form">
<input type="text" placeholder="Enter Keywords">
<select class="selectpicker" id="search-location">
<option value="" selected>Location</option>
<option value="california">California</option>
<option value="las-vegas">Las Vegas</option>
<option value="new-work">New Work</option>
<option value="carolina">Carolina</option>
<option value="chicago">Chicago</option>
<option value="silicon-vally">Silicon Vally</option>
<option value="washington">Washington DC</option>
<option value="neveda">Neveda</option>
</select>
<button class="button primary-bg"><i class="fas fa-search"></i>Search Job</button>
</form>
<div class="trending-key">
<span>Trending Keywords:</span>
designer
php
ios
Android
Accounting
Management
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I need to put two select types side by side which re in different forms
Float and span are not working, I have also tried position-property but of no use.
Below is the HTML code,
form.aui .field-group {
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 4px 0 4px 145px;
position: fixed;
left: 50%;
margin: 1px 0;
width: 100%
}
<div class="xyz-page-panel">
<div class="xyz-page-panel-inner">
<section class="xyz-page-panel-content">
<div id="searchType">
<form class="xyz">
<div class="field-group">
<label for="one-two-id">Search Type </label>
<select name="searchType" class="select long-field" id="one-two-id">
<option value="one">one</option>
<option value="two">two</option>
</select>
</div>
</form>
</div>
<div>
<form class="xyz">
<div class="field-group">
<label for="search-options-id">Search field </label>
<select class="select long-field" id="productName">
<option value="one">one</option>
<option value="two">two</option>
</select>
</div>
</form>
</div>
</section>
</div>
</div>
By using
.xyz-page-panel-content {
display: flex;
}
It's important that you recognize the elements in your structure that are siblings. In your case it's
<div class="xyz-page-panel">
<div class="xyz-page-panel-inner">
<section class="xyz-page-panel-content">
<!-- sibling 1 -->
<div id="searchType">
<!-- ... -->
</div>
<!-- sibling 2 -->
<div>
<!-- ... -->
</div>
</section>
</div>
</div>
For display: flex to work, you must assign this rule to the parent element of those who are meant to be next to each other. If those are not siblings, you have to use some other strategy or change the HTML structure.
You could use float instead by floating the siblings. I don't like using float for layout purposes like these, so I don't show it in action.
.xyz-page-panel-content > * {
float: left ;
}
form.aui .field-group {
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 4px 0 4px 145px;
position: fixed;
left: 50%;
margin: 1px 0;
width: 100%
}
.xyz-page-panel-content {
display: flex;
}
<div class="xyz-page-panel">
<div class="xyz-page-panel-inner">
<section class="xyz-page-panel-content">
<div id="searchType">
<form class="xyz">
<div class="field-group">
<label for="one-two-id">Search Type </label>
<select name="searchType" class="select long-field" id="one-two-id">
<option value="one">one</option>
<option value="two">two</option>
</select>
</div>
</form>
</div>
<div>
<form class="xyz">
<div class="field-group">
<label for="search-options-id">Search field </label>
<select class="select long-field" id="productName">
<option value="one">one</option>
<option value="two">two</option>
</select>
</div>
</form>
</div>
</section>
</div>
</div>
Try to float the divs outside the form tags. This should work.
#searchType {
float:left;
}
Like this
On my product page, there are a number of attributes depending on how many were added to that specific product. It can be from 1 up to 4. The attributes share a common fieldset class name and this is where it gets tricky for me. Basically I'm trying to position 2 of the fieldsets side by side and the rest below them (also side by side). However, I also want them separated and stick to their respective sides within the container. I've managed to make parts of what I said above happen but I have an issue with making the right fieldsets stick to the right side completely. Here's an image description:
Here's the code so far:
https://jsfiddle.net/26za63sh/
HTML:
<div class="container">
<div class="product_attributes clearfix">
<div id="attributes">
<div class="clearfix"></div>
<fieldset class="attribute_fieldset">
<label class="attribute_label" for="group_2">Choose</label>
<div class="attribute_list">
<select name="group_2" id="group_2" class="form-control attribute_select no-print">
<option value="81" selected="selected" title="Option #1">Option #1</option>
<option value="150" title="Option #2">Option #2</option>
</select>
</div>
</fieldset>
<fieldset class="attribute_fieldset">
<label class="attribute_label" for="group_6">Choose</label>
<div class="attribute_list">
<select name="group_6" id="group_6" class="form-control attribute_select no-print">
<option value="31" selected="selected" title="Option #1">Option #1</option>
<option value="56" title="Option #2">Option #2</option>
</select>
</div>
</fieldset>
<fieldset class="attribute_fieldset">
<label class="attribute_label" for="group_5">Choose</label>
<div class="attribute_list">
<select name="group_5" id="group_5" class="form-control attribute_select no-print">
<option value="80" selected="selected" title="Option #1">Option #1</option>
<option value="151" title="Option #2">Option #2</option>
</select>
</div>
</fieldset>
</div>
</div>
</div>
CSS:
.container {
width: 400px;
height: 200px;
background-color: gray;
border: 1px solid #dddddd;
}
fieldset {
padding: 0;
margin: 0;
border: 0;
}
#attributes .attribute_list {
width: 90%;
}
#attributes fieldset {
float: left;
width: 50%;
padding-bottom: 5px;
}
#attributes fieldset:last-child {
float: left;
padding-bottom: 0px;
}
I understand that if I set .attribute_list's width to 100% it will accomplish what I'm trying to do but then the two fieldsets will have no space in the middle. If I instead set a fixed width instead of percentage, then I'll have issues in mobile/tablet view. Any suggestions?
Try this. If you want align items in line and float right.
.attribute-container{display:inline-block;}
.attribute_fieldset:nth-child(odd) .attribute-container{float:right;}
.container {
width: 400px;
height: 200px;
background-color: gray;
border: 1px solid #dddddd;
}
fieldset {
padding: 0;
margin: 0;
border: 0;
}
#attributes .attribute_list {
width: 90%;
}
#attributes fieldset {
float: left;
width: 50%;
padding-bottom: 5px;
}
#attributes fieldset:last-child {
float: left;
padding-bottom: 0px;
}
<div class="container">
<div class="product_attributes clearfix">
<div id="attributes">
<div class="clearfix"></div>
<fieldset class="attribute_fieldset">
<div class="attribute-container">
<label class="attribute_label" for="group_2">Choose 1</label>
<div class="attribute_list">
<select name="group_2" id="group_2" class="form-control attribute_select no-print">
<option value="81" selected="selected" title="Option #1">Option #1</option>
<option value="150" title="Option #2">Option #2</option>
</select>
</div>
</div>
</fieldset>
<fieldset class="attribute_fieldset">
<div class="attribute-container">
<label class="attribute_label" for="group_6">Choose 2</label>
<div class="attribute_list">
<select name="group_6" id="group_6" class="form-control attribute_select no-print">
<option value="31" selected="selected" title="Option #1">Option #1</option>
<option value="56" title="Option #2">Option #2</option>
</select>
</div>
</div>
</fieldset>
<fieldset class="attribute_fieldset">
<div class="attribute-container">
<label class="attribute_label" for="group_5">Choose 3</label>
<div class="attribute_list">
<select name="group_5" id="group_5" class="form-control attribute_select no-print">
<option value="80" selected="selected" title="Option #1">Option #1</option>
<option value="151" title="Option #2">Option #2</option>
</select>
</div>
</div>
</fieldset>
</div>
</div>
</div>
The problem is the elements in fieldset all float to left.
Add this to float the inner elements of odd fieldsets to right:
#attributes fieldset:nth-child(odd) * {
float: right;
}
JSFiddle: https://jsfiddle.net/er_han/Lprh9zqf/
I have three elements in my div dropdown list, input date and button they are all in on div , i want all of them to be in the same line , not under each other
<div id="cont">
Status :
<select id="dropdown">
<option value="Approved">Approved</option>
<option value="Rejected">Rejected</option>
<option value="Pending">Pending</option>
<option value="Error">Error</option>
</select>
<!-- Date Picker -->
<p>Date:
<input type="text" id="datepicker">
</p>
<button type="submit" id="searchBtn" value="">Search</button>
</div>
Use CSS with display: inline-block
.inline {
display: inline-block;
}
<div id="cont">
Status:
<select id="dropdown" class="inline">
<option value="Approved">Approved</option>
<option value="Rejected">Rejected</option>
<option value="Pending">Pending</option>
<option value="Error">Error</option>
</select>
<!-- Date Picker -->
<p class="inline">Date:
<input type="text" id="datepicker">
</p>
<button type="submit" id="searchBtn" value="" class="inline">Search</button>
</div>
Although the above works, it's better practice to put the specific elements in a span tag. Like so ...
.inline {
display: inline-block;
}
<div id="cont">
<span class="inline">Status:
<select id="dropdown">
<option value="Approved">Approved</option>
<option value="Rejected">Rejected</option>
<option value="Pending">Pending</option>
<option value="Error">Error</option>
</select>
</span>
<!-- Date Picker -->
<span class="inline">
<p>Date: <input type="text" id="datepicker"></p>
</span>
<span class="inline">
<button type="submit" id="searchBtn" value="">Search</button>
</span>
</div>
You can add the display: inline-block property to the divs. This will make them get rendered inline with the content, but they keep their block properties, so you can still set their width and height for example.
Example:
.inline {
display: inline-block;
width: 50px;
height: 20px;
}
#red {
background-color: red;
}
#green {
background-color: green;
}
#blue {
background-color: blue;
}
<div class="inline" id="red"></div>
<div class="inline" id="blue"></div>
<div class="inline" id="green"></div>
My favourite tutorial site about the topic: http://learnlayout.com/inline-block.html
This can be used for every element, which supports the display property. Some elements are even set to this by default, like the span element.
https://jsfiddle.net/v9qxobaf/
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
</head>
<style media="screen">
#cont {
margin-left: -20px;
}
.status, .date, .button {
float: left;
padding-left: 20px;
}
</style>
<body>
<div id="cont">
<div class="status">
<label>Status: </label>
<select id="dropdown">
<option value="Approved">Approved</option>
<option value="Rejected">Rejected</option>
<option value="Pending">Pending</option>
<option value="Error">Error</option>
</select>
</div>
<div class="date">
<!-- Date Picker -->
<span> Date: <input type="text" id="datepicker"></span>
</div>
<div class="button">
<button type="submit" id="searchBtn" value="">Search</button>
</div>
</div>
</body>
</html>
wrap each in a div and display: inline-block.
I have this table which has some data (input & select etc...), When any option is not selected, the spacing is correct in all browsers, but when I click on the select the spacing will be changed only in Safari and Chrome but it won't change in Firefox.
Chrome BEFORE clicking on Select
Chrome AFTER clicking on Select
Firefox BEFORE&AFTER clicking on Select
I did not include any code because it works fine in Firefox, and I thought maybe it's some css issue regarding browsers which I should put in my styles, but if needed I will also put my codes.
UPDATE
I added also the codes:
Working jsFiddle
.rTableCell,
.rTableHead {
xfloat: left;
height: 36px;
overflow: hidden;
padding: 3px 3%;
width: 150px;
vertical-align: middle;
line-height: 120%;
display: table-cell;
}
.rTableCellId {
width: 52px;
}
.rTableCellVal {
width: 90px;
vertical-align: middle;
}
<div class="rTable">
<div class="rTableRow" style="color:#797979">
<div class="rTableCell rTableCellId ndLabel">835</div>
<div class="rTableCell ndLabel" style="width:240px;">Visits on the website that end with the purchase</div>
<div class="rTableCell ndLabel" style="width:160px;">LP thank you</div>
<div class="rTableCell rTableCellSrc ndLabel">GA</div>
<div class="rTableCell rTableCellUrlLoc" style="width:180px">
<input id="campaignStructureList0.dataSourceModelList0.urlLocation" name="campaignStructureList[0].dataSourceModelList[0].urlLocation" style="width: 145px;" class="ndInbox" type="text" value="" />
</div>
<div style="margin-top:7px; width: 150px" class="rTableCell rTableCellVal">
<select id="campaignGoalId" name="campaignStructureList[0].dataSourceModelList[0].goalId" style="width:100%">
<option value="">--- Select1 ---</option>
<option value="">--- Select2 ---</option>
</select>
</div>
</div>
<br />
</div>
One option is to set the select's containing div to position:relative;, and the select itself to position: absolute; That takes it out of the flow and thus prevents the resizing of elements.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
.rTableCell,
.rTableHead {
xfloat: left;
height: 36px;
overflow: hidden;
padding: 3px 3%;
width: 150px;
vertical-align: middle;
line-height: 120%;
display: table-cell;
}
.rTableCellId {
width: 52px;
}
.rTableCellVal {
width: 90px;
vertical-align: middle;
}
.rTableCell {position: relative;}
.rTableCell select {position: absolute; left: 20px; top: 12px;}
</style>
</head>
<body>
<div class="rTable">
<div class="rTableRow" style="color:#797979">
<div class="rTableCell rTableCellId ndLabel">835</div>
<div class="rTableCell ndLabel" style="width:240px;">Visits on the website that end with the purchase</div>
<div class="rTableCell ndLabel" style="width:160px;">LP thank you</div>
<div class="rTableCell rTableCellSrc ndLabel">GA</div>
<div class="rTableCell rTableCellUrlLoc" style="width:180px">
<input id="campaignStructureList0.dataSourceModelList0.urlLocation" name="campaignStructureList[0].dataSourceModelList[0].urlLocation" style="width: 145px;" class="ndInbox" type="text" value="" />
</div>
<div style="margin-top:7px; width: 150px; " class="rTableCell rTableCellVal">
<select id="campaignGoalId" name="campaignStructureList[0].dataSourceModelList[0].goalId" >
<option value="">--- Select1 ---</option>
<option value="">--- Select2 ---</option>
</select>
</div>
</div>
<br />
</div>
</body>
</html>
A bit hackish, but if you're not opposed to using a little JavaScript, you can drop down the select on load and immediately close it back up.
window.onload=function(){
var sel = document.getElementById('campaignGoalId');
sel.size=sel.options.length;
sel.size = 1;
}
.rTableCell,
.rTableHead {
xfloat: left;
height: 36px;
overflow: hidden;
padding: 3px 3%;
width: 150px;
vertical-align: middle;
line-height: 120%;
display: table-cell;
}
.rTableCellId {
width: 52px;
}
.rTableCellVal {
width: 90px;
vertical-align: middle;
}
<div class="rTable">
<div class="rTableRow" style="color:#797979">
<div class="rTableCell rTableCellId ndLabel">835</div>
<div class="rTableCell ndLabel" style="width:240px;">Visits on the website that end with the purchase</div>
<div class="rTableCell ndLabel" style="width:160px;">LP thank you</div>
<div class="rTableCell rTableCellSrc ndLabel">GA</div>
<div class="rTableCell rTableCellUrlLoc" style="width:180px">
<input id="campaignStructureList0.dataSourceModelList0.urlLocation" name="campaignStructureList[0].dataSourceModelList[0].urlLocation" style="width: 145px;" class="ndInbox" type="text" value="" />
</div>
<div style="margin-top:7px; width: 150px" class="rTableCell rTableCellVal">
<select id="campaignGoalId" name="campaignStructureList[0].dataSourceModelList[0].goalId" style="width:100%">
<option value="">--- Select1 ---</option>
<option value="">--- Select2 ---</option>
</select>
</div>
</div>
</div>