Images wont display next to each other - html

Im trying to get my two images displayed right next to each other. Currently they keep going under each other. I have searched for some help, but all of it keeps the images the same. I hope some of you can understand the html and css and help me out with this one.
The images are inside each of they own form, and both images has gotten some styling so they have a hover effect.
.container {
position: relative;
width: 400px;
height: 400px;
display: inline-block;
}
.image {
width: 400px;
height: 400px;
}
.overlay {
position: absolute;
transition: all .3s ease;
opacity: 0;
background-color: #eee;
pointer-events: none;
}
.container:hover .overlay{
opacity: 1;
}
.text {
color: white;
font-family: sans-serif;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
font-size: 20px;
}
.overlayFade {
height: 100%;
width: 100%;
top: 0;
left: 0;
background-color: #39598cab;
}
.container:hover .overlayFade{
width: 100%;
}
<center>
<form action="FrontController" method="post">
<h2>Vælg hvilken tag type du ønsker</h2>
<div class="container">
<div class="overlay overlayFade">
<div class="text">
<h1>Spidst tag</h1>
Quick-byg carport med spidst tag
</div>
</div>
<input type="hidden" name="command" value="PointedRoof">
<input type="image" src="./IMAGES/spidsTag.jpg" class="image" value="Spidst Tag">
</div>
</form></center>
<center>
<form action="FrontController" method="post">
<div class="container">
<div class="overlay overlayFade">
<div class="text">
<h1>Fladt tag</h1>
Quick-byg carport med fladt tag
</div>
</div>
<input type="hidden" name="command" value="FlatRoof">
<input type="image" src="./IMAGES/fladtTag.png" class="image" value="Fladt tag">
</div>
</form>
</center>

Images are showing under each other because of the block property.
as Center tag has block property by default.
just add given below css in your stylesheet
center{display: inline-block;}

The best way to do is to use display :flex; and align-items:center to the parent.If you want to align both childs at both ends ,just use justify content :space-between
if you want to learn more about flex visit this link
https://css-tricks.com/snippets/css/a-guide-to-flexbox/

Related

Moving button on top of image

I have two buttons that need to be moved on top of image. One button should be on right side of an image, and another one on the left side. However at the moment they stick at the bottom left corner of the image, while they should be on separate sides in the middle of photo. What I am doing wrong?
HTML part:
<div class="container">
<img class="mySlides" src="images/dog1.jpg" style="width:100%">
<img class="mySlides" src="images/dog2.jpg" style="width:100%">
<img class="mySlides" src="images/dog3.jpg" style="width:100%">
<img class="mySlides" src="images/dog4.jpg" style="width:100%">
<button class="carousell-button carousell-button-black carousell-button-left" onclick="plusDivs(-1)">❮</button>
<button class="carousell-button carousell-button-black carousell-button-right" onclick="plusDivs(1)">❯</button>
</div>
CSS part:
.container carousell-button-right {
position: relative;
top: 200%px;
right: 0%;
}
.container carousell-button-left {
position: absolute;
top: 100%;
left: 0%;
}
How it looks right now:
enter image description here
since you need it in the middle then use Relative to parent and use absolute for Right as well. This will make sure it is positioned absolutely middle based on the image size.
You should also use . for the carousell class.
As mentioned in the comments above 200%px; is an invalid property value.
body {
margin: 0;
}
.container {
position: relative;
}
.container .carousell-button-right {
position: absolute;
top: 50%;
right: 0;
font-size: 30px;
}
.container .carousell-button-left {
position: absolute;
top: 50%;
left: 0;
font-size: 30px;
}
<div class="container">
<img class="mySlides" src="http://placekitten.com/301/301" style="width:100%">
<button class="carousell-button carousell-button-black carousell-button-left" onclick="plusDivs(-1)">❮</button>
<button class="carousell-button carousell-button-black carousell-button-right" onclick="plusDivs(1)">❯</button>
</div>
Look at the snippet below and try to use flex-box
div {
width: 200px;
height: 200px;
background-color: black;
display: flex;
justify-content: center;
align-items: flex-start;
}
button {
width: 50px;
height: 20px;
}
<div>
<button>btn</button>
<button>btn</button>
</div>

How to put custom icons beside input text fields?

I'm looking to create the desired styling in the photo shown. Having trouble getting the custom SVGs I created to be inline with the text field. How would I go about creating this effect?
Here's a snippet of the code I'm using at the minute, where am I going wrong?
I'm mostly using the JQM library if that is of any help.
<div class="box2" style="display: inline-block; position:relative; width: 40vw;">
<img src="img/icon/regicons/usernumber.svg">
<input type="text" name="userNo" id="userNo" placeholder="Number" required><br>
</div>
Ensure that the <input/> has the same height as your <image/> and position it at top of it's parent element.
height: 32px; box-sizing: border-box;
absolute; top: 0;
Snippet:
input {
height: 32px;
box-sizing: border-box;
position: absolute;
top: 0;
}
.box2 {
display: inline-block;
position:relative;
width: 40vw;
}
<div class="box2" style="">
<img width="32" height="32" src="https://lh4.googleusercontent.com/-HhNoCFJ803s/AAAAAAAAAAI/AAAAAAAAAAA/ABtNlbAXJpr-jDsvmXVw0tx4PHId84zrlw/mo/photo.jpg?sz=32">
<input type="text" name="userNo" id="userNo" placeholder="Number" required>
</div>
I would use a flexbox, which is responsive by nature.
.box2 {
display: flex;
background-color: lightgrey;
align-items: center; /* Vertical alignment */
}
<div class="box2" style="position:relative; width: 40vw;">
<img src="https://via.placeholder.com/50x50/00ff00">
<input type="text" name="userNo" id="userNo" placeholder="Number" required><br>
</div>

Center form content vertically

I've got the following landing page form (I've cut all the unnecessary stuff I don't think matters leaving only minimum of style). Here is the code (I'm using Bootstrap 3.3.5):
<div class="col-md-6 app-door">
<form class="image-hover text-center">
<h3>Application name</h3>
<div class="landing-page-form-group">
<label class="landing-page-label">Label: </label>
<input class="form-control landing-page-input">
</div>
<button class="btn">Submit</button>
</form>
<div class="center-block app-link some-img"/>
</div>
..and css
.image-hover {
width: 300px;
height: 300px;
background-color: rgba(0, 0, 0, 0.7) !important;
position: absolute;
z-index: 100;
color: #cccccc;
margin: 0 auto;
left: 0;
right: 0;
border-radius: 25px;
}
.landing-page-form-group {
padding-top: 16px;
padding-bottom: 16px;
}
.landing-page-label {
width: 100px;
vertical-align: middle;
}
.landing-page-input {
width: 150px;
display: inline-block;
}
.app-link {
width: 300px;
height: 300px;
background-size: 100% 100%;
border-radius: 25px;
}
.some-img {
background-image: url("http://dl.hiapphere.com/data/icon/201511/HiAppHere_com_com.ludicside.mrsquare.png");
}
I want to center all the form inputs and etc vertically. I've tried such things as playing with position (relative on parent, absolute on child), vertical-align, top, maybe something else I don't remember right now as I spent lots of hours trying.
I'm not a great specialist in frontend development (I mean html/css) so I will be extremely happy to see understanding although the problem seems to be basic enough.
Thank you for any ideas!
updated
check the solution without flex demo here
Try this
check demo here
add the following styles to your existing .image-hover class
CSS:
.image-hover {
align-items: center;
display: flex;
flex-direction: column;
justify-content: center;
}
Simplest method would be to use
.image-hover {
display: flex;
align-items : center;
justify-content: center;
}
The align-items takes care of vertical centering, and justify-contents, the horizontal centering.
This is my solution:
https://jsfiddle.net/0x9epxah/1/
add div .inner-form:
<div class="col-md-6 app-door">
<form class="image-hover text-center">
<div class="inner-form">
<h3>Application name</h3>
<div class="landing-page-form-group">
<label class="landing-page-label">Label: </label>
<input class="form-control landing-page-input">
</div>
<button class="btn">Submit</button>
</div>
</form>
<div class="center-block app-link some-img"/>
</div>
and this css class:
.inner-form {
position: absolute;
top: 50%; left: 50%;
transform: translate(-50%,-50%);
}

Centering vertically - Position: absolute not working

I have been having problems when trying to center a div vertically. From what I have read I have tried with flexbox but failed and then I tried with position: absolute but also failed, e.g.
HTML:
<div="parent">
<div="child">
<h1>Hello World</h1>
<h3>This is a subtitle</h3>
</div>
</div>
CSS:
.parent{
position: relative;
}
.child{
position: absolute;
top: 50%;
transform: translateY(50%);
}
From what I have been reading this should work, so here is my actual code hoping that you guys can find the solution to my problem.
HTML:
<section class="mainSection">
<div class="container">
<div class="row">
<div class="col-md-8">
<!-- THIS IS THE SECTION THAT I CAN'T GET TO WORK -->
<div class="mainSection-mainTitleWrapper">
<div class="mainSection-mainTitle">
<h1>Creating value</h1>
<h3>Through quality assets</h3>
</div>
</div>
<!-- THIS IS THE END OF THE SECTION THAT I CAN'T GET TO WORK -->
</div>
<div class="col-md-4">
<div class="contactForm">
<h4>Buy, Sale & Rent</h4>
<p>Lorem ipsum is simply dummy text of the printing and typesetting industry. Lorem ipsum has been the industry's standard dummy text.</p>
<form>
<input type="text" name="user_name" placeholder="FULL NAME">
<input type="emial" name="user_email" placeholder="EMAIL">
<input type="tel" name="user_phone" placeholder="PHONE">
<select>
<option value="buy">BUY</option>
<option value="sale">SALE</option>
<option value="rent">RENT</option>
</select>
<select>
<option value="price" disabled selected>PRICE</option>
<option><$100,000.00</option>
<option><$200,000.00</option>
<option><$400,000.00</option>
<option><$600,000.00</option>
<option><$1,000,000.00</option>
</select>
<input type="submit" name="find" value="FIND NOW">
</form>
</div>
</div>
</div>
</div>
</section>
CSS:
.mainSection{
background: url('img/background.jpg') no-repeat center center;
background-size: cover;
box-shadow: inset 0 0 0 1000px rgba(0,0,0,0.4);
padding-bottom: 50px;
}
.mainSection-mainTitleWrapper{
position: relative;
}
.mainSection-mainTitle{
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.mainSection-mainTitle h1{
font-size: 65px;
color: #fff;
font-weight: bold;
text-transform: uppercase;
}
.mainSection-mainTitle h3{
font-size: 35px;
color: #fff;
font-weight: bold;
text-transform: uppercase;
}
Sorry for the lengthy question, but does anyone have an idea of why is it not working or another possible solution to vertically center the .mainSection-mainTitle div?
Vertical align middle works, but you will have to use table-cell on your parent element and inline-block on the child.
This solution is not going to work in IE6 & 7.
The classic solution (table layout)
Look at this fiddle:
http://jsfiddle.net/mcSfe/
Tested in:
FF3.5
FF4
Safari 5
Chrome 11 & 12
IE9
HTML
Your parent div must have a set hight. Otherwise the child will not know what 50% of nothing is.
<div class="cn">
<div class="inner">your content</div>
</div>
CSS
.cn {
display: table-cell;
width: 500px;
height: 500px;
vertical-align: middle;
text-align: center;
}
.inner {
display: inline-block;
width: 200px; height: 200px;
}
Modern solution (transform)
Since transforms are fairly well supported now (http://caniuse.com/#search=2d%20transforms) there is an easier way to do it.
CSS
.cn {
position: relative;
width: 500px;
height: 500px;
}
.inner {
position: absolute;
top: 50%; left: 50%;
transform: translate(-50%,-50%);
width: 200px;
height: 200px;
}
Look here:
http://jsfiddle.net/0tc6ycvo/1/

Displaying images in a row and indicating selection - HTML and CSS

What I would like to achieve (the goal)...
I'm trying to display a row of images (with the image name below the image) in html, like so:
When a user clicks on an image I want a square to appear over the image, to indicated selection like so (user has clicked on Tile1):
What I have done so far...
So far I have managed to display the tiles in a row:
Here's the html code that produced the image above:
<div id='default_tiles_view'>
<div class="default_tiles_view_square" id="tile1">
<img src="https://raw.github.com/andrespagella/Making-Isometric-Real-time-Games/master/img/tile.png">
<p>Tile1</p>
</div>
<div class="default_tiles_view_square" id="tile2">
<img src="https://raw.github.com/andrespagella/Making-Isometric-Real-time-Games/master/img/dirt.png">
<p>Tile2</p>
</div>
</div>
And the CSS:
#default_tiles_view {
width: 490px;
height: 160px;
overflow-y: auto;
}
.default_tiles_view_square {
display: inline-block;
}
.default_tiles_view_square p {
text-align: center;
}
And a fiddle showing the example above: http://jsfiddle.net/jamiefearon/t8d6U/
The strategy to achieve the goal...
I was thinking about wrapping the image and its title in a div, and then changing the background colour of the div. Here is the result and the code:
HTML:
<div id='default_tiles_view'>
<div class="tile_wrap" id="tile1">
<div class="default_tiles_view_square">
<img src="https://raw.github.com/andrespagella/Making-Isometric-Real-time-Games/master/img/tile.png">
<p>Tile1</p>
</div>
</div>
<div class="tile_wrap" id="tile2">
<div class="default_tiles_view_square">
<img src="https://raw.github.com/andrespagella/Making-Isometric-Real-time-Games/master/img/dirt.png">
<p>Tile2</p>
</div>
</div>
</div>
CSS:
#default_tiles_view {
width: 490px;
height: 160px;
overflow-y: auto;
}
.tile_wrap {
display: inline-block;
}
.default_tiles_view_square p {
text-align: center;
}
#tile1 {
background-color:red;
}
The Problem..
It does not look good, and the actual image is not covered by the red colour. Maybe it would be possible to overlay a div over the wrap div, set it's opacity < 1 and change its background colour.
What do think? Does anyone have any ideas of a good way to achieve the goal?
Something like this should do the trick: http://jsfiddle.net/t8d6U/1/
So just hide the overlay DIVs initially with display:none (or e.g. left:-9999px) then show them onClick.
CSS:
#default_tiles_view {
overflow: auto;
}
.default_tiles_view_square {
float: left;
margin: 5px 10px 10px 10px;
position: relative;
height: 128px;
width: 128px;
}
.default_tiles_view_square p {
text-align: center;
}
.content {
position: absolute;
z-index: 1;
top: 0;
left: 0;
}
.overlay {
position: absolute;
z-index: 2;
background: red;
opacity: 0.5;
height: 128px;
width: 128px;
top: 0;
left: 0;
}
HTML:
<div id='default_tiles_view'>
<div class="default_tiles_view_square" id="tile1">
<div class="content">
<img src="https://raw.github.com/andrespagella/Making-Isometric-Real-time-Games/master/img/tile.png">
<p>Tile1</p>
</div>
<div class="overlay"></div>
</div>
<div class="default_tiles_view_square" id="tile2">
<div class="content">
<img src="https://raw.github.com/andrespagella/Making-Isometric-Real-time-Games/master/img/dirt.png">
<p>Tile2</p>
</div>
<div class="overlay"></div>
</div>
</div>
I have taken what Gaurav said in the comments, changing the opacity:
HTML
<div id='default_tiles_view'>
<div class="tile_wrap" id="tile1">
<div class="default_tiles_view_square">
<img src="https://raw.github.com/andrespagella/Making-Isometric-Real-time-Games/master/img/tile.png">
<p>Tile1</p>
</div>
</div>
<div class="tile_wrap" id="tile2">
<div class="default_tiles_view_square">
<img src="https://raw.github.com/andrespagella/Making-Isometric-Real-time-Games/master/img/dirt.png">
<p>Tile2</p>
</div>
</div>
</div>
CSS
#default_tiles_view {
width: 490px;
height: 160px;
overflow-y: auto;
}
#tile1:hover{
background:red;
opacity:0.4;
}
.tile_wrap {
display: inline-block;
}
.default_tiles_view_square p {
text-align: center;
}
Fiddle: http://jsfiddle.net/jamiefearon/BY9Fp/
Hover over Tile1 to see the effect.