How do you apply z-index on parallax image - css

I am trying to overlap my survey form over a parallax image (creating using MateralizeCss) using Z-index. However, my form still remains under the image. Please help! *Cant provide my codes as it is in xslt. Any simple example will be appreciated.
This is the html code
<div class="parallax-container">
<div class="parallax">
<img src="http://materializecss.com/images/parallax1.jpg" />
</div>
</div>
<div style="width:50%;margin: 0 auto ;z-index:1000;background-color:white;padding:2.5%; box-shadow: 0px 4px 5px gray,
-5px 4px 7px gray, 5px 4px 7px gray;margin-bottom:5%;position:absolute">
<div style="font-size:250%;font-weight:bold">In Store Hub Trooper Feedback Form</div>
<div style="font-size:150%;">Q number</div>
<div>
<input type="number" required="required" />
</div>
<div style="font-size:150%;">Dateeeeeeeeeeeeee</div>
<div id="input">
<input type="date" class="datepicker" required="required">
</input>
<span>
</span>
</div>

Both the form and the image will need a position property.
HTML
<form id="myform" class="overlap">
<button id="button" name="button">A button</button>
<br/>
<input type="submit" value="submit">
</form>
<div class="box">
Thing overlapping with form
</div>
CSS
.overlap {
position: relative;
margin: 0 auto;
background-color: #ccc;
padding: 3em;
width: 50%;
}
.box {
position: absolute;
top: 6em;
right: 20%;
background-color: #666;
color: #fff;
padding: 3em;
width: 25%;
}
I made you a CodePen:
See the Pen Overlapping things with z-index by Yvonne Aburrow (#vogelbeere) on CodePen.
EDIT: I added my answer before you updated the question with your code.

Related

Align input[submit] with text field

I'm a CSS/HTML newbie and have tried to do research on this but am stumped. I've seen others with a similar problem, but their submit button and text field are only slightly misaligned. Mine is vertical but I want it horizontal.
I tried adding display: inline-block to both the text field and submit button elements, but it didn't fix the issue.
Here is the embed code for the form:
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="https://julienkozak.us14.list-manage.com/subscribe/post?
u=f46b7a895f8d332e0127067ad&id=4fbc88f22f" method="post" id="mc-
embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate"
target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<div class="mc-field-group">
<input type="email" value="" name="EMAIL" class="required email" id="mce-
EMAIL" placeholder="e-mail address">
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none">
</div>
<div class="response" id="mce-success-response" style="display:none">
</div>
</div> <!-- real people should not fill this in and expect good things -
do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input
type="text" name="b_f46b7a895f8d332e0127067ad_4fbc88f22f" tabindex="-1"
value=""></div>
<div class="clear" ><input type="submit" value="Get Updates"
name="subscribe" id="mc-embedded-subscribe" class="button"></div>
</div>
</form>
</div>
<!--End mc_embed_signup-->
The rest of the code you see is the CSS :
/* MAILCHIMP top form */
#mc_embed_signup {
text-align: center;
width: 300px;
}
/* Styles the header text above the inputs */
#mc_embed_signup h2 {
font-size: 18px;
margin: 0 0 20px;
color: #000000;
text-align: center;
}
/* Adds extra space around the input boxes */
#mc_embed_signup .mc-field-group {
padding: 10px 0;
}
/* Styles the input boxes */
#mc_embed_signup input {
width: 200px;
background: white;
height: 40px;
border-radius: 0px;
display: inline-block;
}
/* Styles the subscribe button */
#mc_embed_signup .button {
background-color: gray;
color: #ffffff;
margin: 0 auto;
width: 100px;
height: 40px;
display: inline-block;
}
julienkozak.com/ The form is at the top of this page.
Thank you so much for your patience with me.
Have you considered using bootstrap?
You could also use bootstrap's row functionality to dynamically set the fields of your div tag to a certain part of the page. This has the added benefit of making your page responsive to a variety of screens and monitors.
You can use flexbox on the wrapping div mc_embed_signup_scroll using display:flex. I put margin-top:10px on the button to align it with the input field.
/* MAILCHIMP top form */
#mc_embed_signup {
text-align: center;
width: 300px;
}
/* Styles the header text above the inputs */
#mc_embed_signup h2 {
font-size: 18px;
margin: 0 0 20px;
color: #000000;
text-align: center;
}
/* Adds extra space around the input boxes */
#mc_embed_signup .mc-field-group {
padding: 10px 0;
}
/* Styles the input boxes */
#mc_embed_signup input {
width: 200px;
background: white;
height: 40px;
border-radius: 0px;
}
/* Styles the subscribe button */
#mc_embed_signup .button {
background-color: gray;
color: #ffffff;
margin: 0 auto;
width: 100px;
height: 40px;
margin-top:10px;
}
#mc_embed_signup_scroll{display:flex}
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="https://julienkozak.us14.list-manage.com/subscribe/post?
u=f46b7a895f8d332e0127067ad&id=4fbc88f22f" method="post" id="mc-
embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<div class="mc-field-group">
<input type="email" value="" name="EMAIL" class="required email" id="mce-
EMAIL" placeholder="e-mail address">
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none">
</div>
<div class="response" id="mce-success-response" style="display:none">
</div>
</div>
<!-- real people should not fill this in and expect good things -
do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_f46b7a895f8d332e0127067ad_4fbc88f22f" tabindex="-1" value=""></div>
<div class="clear"><input type="submit" value="Get Updates" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
</div>
</form>
</div>

CSS - How to line up buttons?

I am trying to create a form with multiple rows. Each row has an optional input field followed by a mandatory button. The buttons should line up vertically - something like this:
_____________ _______________
| input 1 | | button 1 |
|___________| |_____________|
_______________
| button 2 |
|_____________|
I tried to float the button left with a fixed left margin, but doing so moves the input field to the right of the button - even though the input field appears first in the markup:
<div>
<input type="text">
<button>Action 1</button>
</div>
Please see my jsfiddle here. Why is this happening and what's the correct solution?
You need thee div container to do this as shown in this jsFiddle.
HTML Code
<div class="container">
<div class="left">
<button>
</div>
<div class="right">
<button>
</div>
</div>
CSS Code
.container {
width: 190px;
height: 22px;
margin: 0;
}
.left {
float: left;
width: 95px;
height: 22px;
}
.right {
float: right;
width: 95px;
height: 22px;
}
​
Use rows.
<div class="row-rap">
<div class="right">
<input type="text">
</div>
<div class="left">
<input type="button" value="Action 1">
</div>
</div>
<div class="row-rap">
<div class="right">
<input type="text">
</div>
<div class="left">
<input type="button" value="Action 2">
</div>
</div>​
With the following styling.
div.row-rap {
width: 100%;
}
div.row-rap .right, div.row-rap .left {
width: 50%;
float: left;
}
Here's an alternative, the margins and colors may need modification. See jsfiddle link for sample result.
It has a left-aligned label and right-aligned input (button style) in a div, for each line. The non-breaking space is needed as a placeholder in the span element that represents an "empty label".
http://jsfiddle.net/qallar/kfgCb/5/
The html is:
<div class='line'>
<span class='formlabel'>label 1</span>
<input class='formbutton' type='button' value='button 1 text ' />
</div>
<div class='line'>
<span class='formlabel'> </span>
<input class='formbutton' type='button' value='button 2 text' />
</div>
and the css:
.line
{
display: block;
background-color: #ddd; /* also try #fff */
margin: 0px;
padding: 2px;
height: 30px;
width: 200px;
}
.formlabel
{
float: left;
background-color: #eee; /* also try #fff */
margin: 0px;
padding: 2px;
width: 75px;
height: 100%;
clear: both;
}
.formbutton
{
float: right;
background-color: #0f0;
margin: 0px;
padding: 0px;
width: 100px;
height: 100%;
}
The input field is flying to the right of the button because it is an inline element. Float works on block elements only, inline elements will always flow around the floated elements. This explains the behavior in the original jsFiddle.
Having said that, even if I put display:block on the input element it still behaves like inline. I was able to make the basic concept work for a div though, which is a true block element. See the jsFiddle here.
<div class="row">
<button>Action 1</button>
<div class="in"></div>
</div>
.row {
clear: both;
}
.in {
background-color: green;
height: 24px;
width: 100px;
}
button {
float: left;
margin-left: 110px;
width: 150px;
}
The only workaround seems to be the one offered by Musa (see this jsFiddle) where he aligns the buttons to the right using text-align and limiting the width of the div.
I am not a CSS expert and usually this task works for me using table
<table>
<tr><td>Optional Input</td><td>Button</td></tr>
<tr><td>Optional Input</td><td>Button</td></tr>
</table>
if table by some reason is not an option you can use div/span
<div style="display: table-row">
<span style="display: table-cell">Optional Input</span>
<span style="display: table-cell">Button</span>
</div>
It will about like this
using Block formatting context https://developer.mozilla.org/en-US/docs/CSS/Block_formatting_context
jsfiddle code: http://jsfiddle.net/EeNFH/9/
the html code:
<div class="inp">
<input type="text">
</div>
<div class="btns">
<p><button>Action 1</button></p>
<p><button>Action 2</button></p>
</div>
and the styles:
input {
width: 100px;
}
button {
width: 150px;
}
.inp{
float:left;
}
.btns{
overflow:hidden;
}
​

Add an Image on top of another image

The UI of my page currently shows an Image in backgroud and text on left hand top corner of the page. Following is the code I am using for the image.
<div>
<div style= "z-index: 1; position: absolute; text-align: left; border: 1px solid black;">
<img src="slide1.jpg" alt="alt text" style="height:220px;width:500px;border-width:0px;" />
</div>
<div id="curtain" style="z-index: 2; position: absolute; padding-left: 10px;">
<div style="background-color: transparent; font-weight: bold; font-size: 1.8em; padding-top: 5px;">
Profile
</div>
<div style="font-size: 1em; width: 215px; color: #cccccc;">
He is a good citizen and a great teacher.
</div>
</div>
</div>
I want to add 2 small icons aligned vertically on the right hand side of this image.
Can someone help me with the css ?
Something like this?
http://jsfiddle.net/7KTEQ/
Just add <div id="smallImages"><img src='ONE' /> <img src='two' /></div> inside second div
and css for it is:
#smallImages {
position:absolute;
margin-left:400px;
}​
change margin-left for css depending on second div width and image sizes..

css - have two inline inputs take up remaining space

I have the following html:
<div id="holder">
<span>Search for</span>
<input id="srchfor" />
<span>near</span>
<input id="srchin" />
<span>submit</span>
</div>
The containing div is fixed width. The width of the 3 spans will depend on font size. Is it possible to make the two inputs take a width so that they are both equally sized, and they consume all the remaining space in holder? Or does this require using javascript?
Edit: My aim is to have the 5 elements all on one line, rather than split over several lines.
This is an old post but I came across it and figured I would answer it for the next person. Here is a CSS/HTML snippet that should resolve this issue. It is kind of like a HTML5 flexbox but without HTML5 or a flexbox. You can add width to whatever 2 sections needed and the third will fill the remaining void.
<style type="text/css">
.form-group {
border: 1px solid black;
margin-bottom: 20px;
padding: 10px;
width: 75%;
}
.a {
float: right;
margin-left: 10px;
width: 30%;
}
.a input {
width: 100%;
}
.b {
float: left;
margin-right: 10px;
width: 33%;
}
.b input {
width: 100%;
}
.c {
display: block;
overflow: hidden;
}
.c input {
width: 100%;
}
</style>
<div id="wrapper">
<div class="form-group">
<span class="a">
<label>Thing 1</label><br />
<input type="text" />
</span>
<span class="b">
<label>Thing 2</label><br />
<input type="text" />
</span>
<span class="c">
<label>Thing 3</label><br>
<input type="text" />
</span>
</div>
<div class="form-group">
<div class="a">
<label>Thing 1</label><br />
<input type="text" />
</div>
<div class="b">
<label>Thing 2</label><br />
<input type="text" />
</div>
<div class="c">
<label>Thing 3</label><br>
<input type="text" />
</div>
</div>
</div>
Well, you could change the display type from display: inline to display: block to make them fill space. But I don't know if the inline is an requirement.
You have to choose a fixed width for the span elements, and use the display:inline-block property like in this example.

How to layout a image gallery?

I am making an image gallery, and I need to display images in a grid like layout. I don't want to use any frameworks, and would prefer to do things from scratch. Also, I would prefer not to use tables for the layout, since it will be a pain to add images to the table dynamically.
The layout consists of divs, like:
<div id="gallery">
<div class="uPic">
<img src="1.png">
<p> description </p>
</div>
<div class="uPic">
<img src="2.png">
<p> description </p>
</div>
....
......
....
</div>
to achieve the grid look, I simply "float"-ed all .uPics to left....and given some padding and margin to the #gallery. So far everything works great.
The PROBLEM starts, when I try to give a hover effect to the images. initially the <p> is hidden, and I use jQuery to show it on hover. but on doing so, the images below the one I am hovering over, shifts towards the right instead of moving down. Any ideas?
If the height of your divs is variable then I would recommend either using clear:both on the first element of each new row OR putting each row in its own container div. Otherwise, as you've noticed, the divs under the selected one will probably be pushed to the side of the higher div instead of shifting down.
I'd also consider Matt's solution as divs moving around on mouseover imho gives a very chaotic look to a page.
But if you're set on doing it this way, check out this example:
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready( function() {
$('#gallery .image p').hide();
$('#gallery .image').hover(
function() { $(this).find('p').show() },
function() { $(this).find('p').hide() }
);
});
</script>
<style>
#gallery {
width: 800px;
}
#gallery .image {
width: 200px;
float: left;
background: #eee;
margin-bottom: 10px;
}
#gallery .image.newline {
clear: both;
}
#gallery .image .placeholder {
width: 180px;
height: 200px;
margin: 10px;
background: #ccf;
}
#gallery .image p {
margin: 10px;
background: #fcc;
}
</style>
</head>
<body>
<div id="gallery">
<div class="image">
<div class="placeholder"></div>
<p>My description</p>
</div>
<div class="image">
<div class="placeholder"></div>
<p>My description</p>
</div>
<div class="image">
<div class="placeholder"></div>
<p>My description</p>
</div>
<div class="image">
<div class="placeholder"></div>
<p>My description</p>
</div>
<!-- NOTE the added "newline" class where the new line starts! -->
<div class="image newline">
<div class="placeholder"></div>
<p>My description</p>
</div>
<div class="image">
<div class="placeholder"></div>
<p>My description</p>
</div>
<div class="image">
<div class="placeholder"></div>
<p>My description</p>
</div>
</div>
</body>
</html>
The w3schools has a sample image gallery all in CSS. They add a border on hover of the image.
I would maybe set the width and height of the paragraph, and fix it using absolute positioning relative to the enclosing uPic div. That way you can have the paragraph of description appear "above" the image on hover without disturbing the flow. So, add position: relative; to the uPic, add something along the lines of position: absolute; left: 0px; top: 0px; to the <p>, and then adjust other things to suit.
I suggest that you choose a fixed height and width for your div :
It may fix your problem
It is not convenient for the user when a whole part of the grid is moving just to show up a little description, whether it is downward or to the right
I think this may be helpful
<style type="text/css" ><!--
#gallery_box{
width:728px;
height:545px;
border:solid #cccccc 1px;
margin:20px auto 0px;
padding:5px;
-moz-box-shadow:0px 18px 40px #ccc;
-webkit-box-shadow:0px 14px 40px
#ccc;
box-shadow:0px 5px 30px #ccc;
}
#thumbnail{
width:160px;
height:160px;
background:#f6f6f6;
border:solid #cccccc 1px;
border:solid #cccccc 1px;
margin:5px;
padding:5px;
float:left;
text-align:center;
position: relative;
line-height: 156px;
-moz-box-shadow:4px 4px 4px
#ccc;n-webkit-box-shadow:4px 4px 4px #ccc; box-shadow: 4px 4px 4px #ccc; } img {
border:none;
-moz-box-shadow:0px 8px 10px #ccc;
-webkit-box-shadow:0px 8px 10px #ccc; box-shadow: 0px 8px 10px #ccc; }
a{
color:#0066FF; text-decoration:none;
} a:hover{
color:#0099FF; }
--></style><pre>
<div id="gallery_box" >
<div id="thumbnail">
<a href="" ></a>
</div>
</div>

Resources