I'm trying to add UI elements over the top of an image by using pure HTML and CSS only. Here's the expected result
My code is working as expected but there are two issues. Here are the issues:
When I changed the image into a Adobe Illustrator one the UI elements are disappeared
SOLVED At certain point the background image will not responsive while the UI elements keep changing it size when the window is upsized
Any idea where did I go wrong? This is my attempt
.plane-container {
position: relative;
max-width:100%;
max-height:100%;
}
.deck {
display: flex;
}
.arrow {
display: flex;
align-items: center;
justify-content: center;
}
.plane-container .overlay .main-deck {
width: 67%;
height: 23%;
margin-top: 19.3%;
margin-left: 16.5%;
position: absolute;
}
.plane-container .overlay .lover-deck {
width: 20.3%;
height: 10%;
margin-top: 27.2%;
margin-left: 16.5%;
position: absolute;
}
.plane-container .overlay .aft-deck {
width: 16.7%;
height: 10%;
margin-top: 27.2%;
margin-left: 55%;
position: absolute;
}
.plane-container div img {
position: relative;
max-width:100%;
max-height:100%;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="plane-container">
<div class="overlay">
<div class="main-deck deck">
<div class="arrow" style="width: 5%;">
<i class="fa fa-angle-left"></i>
</div>
<div style="background:blue; width: 90%; height: 100%;">
</div>
<div class="arrow" style="width: 5%;">
<i class="fa fa-angle-right"></i>
</div>
</div>
<div class="lover-deck deck">
<div class="arrow" style="width: 10%;">
<i class="fa fa-angle-left"></i>
</div>
<div style="background:red; width: 80%; height: 100%;">
</div>
<div class="arrow" style="width: 10%;">
<i class="fa fa-angle-right"></i>
</div>
</div>
<div class="aft-deck deck">
<div class="arrow" style="width: 10%;">
<i class="fa fa-angle-left"></i>
</div>
<div style="background:purple; width: 80%; height: 100%;">
</div>
<div class="arrow" style="width: 10%;">
<i class="fa fa-angle-right"></i>
</div>
</div>
</div>
<div>
<!-- Image from Adobe Illustrator -->
<!-- <img src="https://i.postimg.cc/j5ggYMjt/from-ai.png" /> -->
<!-- Original Image -->
<img src="https://i.postimg.cc/V6ypHG5T/red.png"/>
</div>
</div>
And here's the JSFiddle link
EDIT 1
Problem 2 is solved by Terek Janczik
Add this line to your code to fix the boxes not sitting in the correct location when the screen is resized beyond a certain width:
.plane-container div img{
width:100%;
}
Related
My question is how to position these cards on my website?
https://imgur.com/a/Ompfh
It would be easy if there isn't this half circles above them.
I have tried to create parent class="cards" and class="card" for each of 3 cards.
In css:
.cards { display: flex }
.card { width: 33.33% }
And set relative position to my background and absolute position to my half-circles but I want to do it without absolute and relative positions if it's possible.
.cards {
display: flex;
}
.card {
width: 33.33%;
color: #fff;
text-align: center;
}
.card p {
min-height: 80px;
padding: 0 39px 0 39px;
}
.strategy--logo {
position: absolute;
top: 383px;
left: 607px;
width: 96px;
height: 48px;
background-color: #5a471b;
border-top-right-radius: 48px;
border-top-left-radius: 48px;
}
.strategy {
margin-top: 135px;
background-color: #5a471b;
}
.crop--marketing {
margin-top: 135px;
background-color: #9fa374;
}
.risk--mgmt {
margin-top: 135px;
background-color: #666;
}
<div class="cards">
<div class="card">
<div class="strategy">
<div class="strategy--logo">
<img src="css/images/strategy-logo.png" alt="" />
</div>
<!-- /.strategy-/-logo -->
<h2>
</h2>
<p>
</p>
</div>
<!-- /.crop-/-marketing -->
</div>
<!-- /.card -->
<div class="card">
<div class="crop--marketing">
<img src="css/images/crop-logo.png" alt="" />
<h2>
</h2>
<p>
</p>
</div>
<!-- /.crop-/-marketing -->
</div>
<!-- /.card -->
<div class="card">
<div class="risk--mgmt">
<img src="css/images/arrow-logo.png" alt="" />
<h2>
</h2>
<p>
</p>
</div>
<!-- /.risk-/-mgmt -->
</div>
<!-- /.card -->
</div>
<!-- /.cards -->
Now I'm using absolute and relative but is there another way? Because when I resize my web browser the circles go away random ...
Are you trying to achieve this?
.card {
displaY: block;
float: left;
width: 33.33%;
text-align: center;
color: white;
font-family: 'Calibri';
}
.icon {
width: 50px;
height: 25px;
/*half of width*/
margin: auto;
display: block;
border-radius: 50px 50px 0 0;
}
.fa {
margin-top: 10px;
}
.text {
padding: 25px;
}
.strategy .text,
.strategy .icon {
background-color: #5c471c;
}
.crop .text,
.crop .icon {
background-color: #a0a175;
}
.risk .text,
.risk .icon {
background-color: #666666;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet" />
<div class="card strategy">
<div class="icon">
<i class="fa fa-area-chart" aria-hidden="true"></i>
</div>
<div class="text">
Our Strategy
</div>
</div>
<div class="card crop">
<div class="icon">
<i class="fa fa-pagelines" aria-hidden="true"></i>
</div>
<div class="text">
Crop Marketing
</div>
</div>
<div class="card risk">
<div class="icon">
<i class="fa fa-arrow-down" aria-hidden="true"></i>
<i class="fa fa-arrow-up" aria-hidden="true"></i>
</div>
<div class="text">
Commodity Risk Management
</div>
</div>
Is the main problem that when you use position your layout changes its position elsewhere?
If so, to use position property is ok if you make a few changes:
CSS
.strategy--logo {
position: absolute;
/* Remove this top parameter, use transform instead */
/* top:383px; */
/* Instead your value of a left use value of 50% and transform left
and right properties like it is changed below */
/* left: 607px; */
left: 50%;
transform: translate(-50%, -100%);
width: 96px; height: 48px;
background-color: #5a471b;
border-top-right-radius: 48px;
border-top-left-radius: 48px;
}
.strategy {
/* add position relative to a parent of strategy-logo */
position: relative;
margin-top: 135px;
background-color: #5a471b;
}
Then your code will stay in the same position even if you resize the screen.
Hello,
As you can see from the photo above, I am trying to achieve a grid system. First grid is 3 images, second grid is a column, and third grid is a large image floated to the right of the 2nd grid. You can see this photo on my portfolio website: http://www.irwinlitvak.com
I have three images in the first grid that have a width of 31.33% and the first and second img have a margin-right of 3.005% to full up the container width.
In the next grid (grid-2), I have a two of my images floated left in a column and (grid-2-of-3) is floated right with a width of 65.556%.
I would like the top and bottom of the larger image to take up the full height of the grid, so the bottom of the big image aligns with the self-destructing box.
Here is the HTML & CSS:
.projects-grid {
margin: 100px auto 0;
width: 90%;
}
.projects-grid .title {
margin-bottom: 20px;
text-align: center;
}
.projects-grid h1 {
display: inline-block;
font-family: "Montserrat";
}
.grid-1 {
margin-bottom: 4%;
}
.grid-1-of-3 {
position: relative;
width: 31.33%;
float: left;
overflow: hidden;
}
.grid-2-of-3 {
position: relative;
width: 65.556%;
float: right;
}
.grid-1-of-3:first-child,
.grid-1-of-3:nth-child(2) {
margin-right: 3.005%;
}
.grid-3 {
position: relative;
display: inline-block;
width: 33%;
margin-bottom: 60px;
vertical-align: bottom;
}
.grid-5 {
position: relative;
display: inline-block;
width: 20%;
margin-bottom: 60px;
vertical-align: bottom;
}
.box-1 {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
}
.grid-1-of-3:first-child {
margin-left: 0;
}
.grid-1-of-3:last-child {
margin-right: 0;
}
.big-box {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
}
.grid-2 {
width: 31.33%;
float: left;
}
.grid-2 .box-cont {
width: 100%;
}
.grid-2 .box-cont:first-child {
margin-bottom: 4%;
}
.grid-2 .box-cont {
position: relative;
}
<section class="projects-grid clearfix">
<div class="row title">
<h2>Projects</h2>
</div>
<div class="grid-1 clearfix">
<div class="grid-1-of-3">
<div class="box-1">
<a href="">
<img class="bdgt-app" src="assets/budget-app-x-ps.jpg" alt="budget-app pic">
</a>
<a href="https://budget-app-x.herokuapp.com/" target="_blank">
<div class="box-overlay">
<div class="text-overlay">
<h3>Budget-App-X</h3>
<p>Manage your incomes and expenses in a fun and easy app.</p>
</div>
</div>
</a>
</div>
<h3>
Budget-App-X
</h3>
</div>
<div class="grid-1-of-3">
<div class="box-1">
<a href="">
<img src="/assets/dice-game-x-ps.jpg" alt="dice-game">
</a>
<a href="https://dice-game-x.herokuapp.com/" target="_blank">
<div class="box-overlay">
<div class="text-overlay">
<h3>Dice-Game</h3>
<p>Roll the dice. Test your luck and see who racks the most points.</p>
</div>
</div>
</a>
</div>
<h3>
Dice-Game
</h3>
</div>
<div class="grid-1-of-3">
<div class="box-1">
<a href="">
<img src="/assets/pomodoro-timer-x-ps.jpg" alt="pomodoro-app-timer">
</a>
<a href="http://pomodoro-app-timer.herokuapp.com" target="_blank">
<div class="box-overlay">
<div class="text-overlay">
<h3>Pomodoro-Timer</h3>
<p>A quick and easy solution to being productive. Set the time and get things done.</p>
</div>
</div>
</a>
</div>
<h3>
Pomodoro-Timer
</h3>
</div>
</div>
<div class="grid-2 clearfix">
<div class="box-cont">
<div class="box-1">
<a href="">
<img src="/assets/cucumberme-x-ps.jpg" alt="cucumber me">
</a>
<a href="http://www.cucumberme.com" target="_blank">
<div class="box-overlay">
<div class="text-overlay">
<h3>CucumberMe</h3>
<p>CucumberMe is your way of anonymously sending cucumbers to a friend, ex or anyone you want.<br><br> Go and send one today! </p>
</div>
</div>
</a>
</div>
<h3>
CucumberMe
</h3>
</div>
<div class="box-cont">
<div class="box-1">
<a href="#">
<img src="/assets/self-destruct-x-ps.jpg" alt="to do list">
</a>
<a href="http://todos-irwin.herokuapp.com/" target="_blank">
<div class="box-overlay">
<div class="text-overlay">
<h3>Self Destructing To-Do-List</h3>
<p>A to-do-list that will delete itself within 10 seconds. How many chores can you list within that time? </p>
</div>
</div>
</a>
</div>
<h3>
<a href="http://todos-irwin.herokuapp.com/" target="_blank">
Self Destructing To-Do-List
</a>
</h3>
</div>
</div>
<div class="grid-2-of-3 clearfix">
<div class="box-cont">
<div class="big-box">
<a href="#">
<img src="/assets/omnifood-x-ps.jpg" alt="omnifood">
</a>
<a href="http://con.staging.thegateny.net/con/Omnifood/v1/" target="_blank">
<div class="box-overlay big-overlay">
<div class="text-overlay">
<h3>Omnifood</h3>
<p>My version of the food app Blue Apron. Take a look! </p>
</div>
</div>
</a>
</div>
<h3>
<a href="http://con.staging.thegateny.net/con/Omnifood/v1/" target="_blank">
Omnifood
</a>
</h3>
</div>
</div>
</section>
What you can do is as I show in the snippet below. You have a container for all your divs you want at the same height, which you give a set height. You then give the items on the left a container (with height: 100%) and make a div for the right item (height: 100%).
By doing this, you have a container for the items on the left, so you can make them, say, 50% each, and you have a right item that's the same height as the container on the left.
In order to make an image fit a div, either use background-size: cover or something similar. height:100%; width: auto also works for responsive images.
Hope it helps.
.outer {
background: blue;
width: 600px;
height: 200px;
}
.leftwrap {
width: 30%;
float: left;
height: 100%;
}
.left1 {
background: purple;
width: 100%;
height: 50%;
}
.left2 {
background: orange;
width: 100%;
height: 50%;
}
.right {
background: teal;
height: 100%;
width: 70%;
float: left;
}
/** New code **/
.image {
height: 80%;
width: auto;
border: 1px solid black;
}
.imagetext {
color: white;
text-align: center;
border: 1px solid black;
}
.left {
box-sizing: border-box;
padding-bottom: 30px;
}
<div class='outer'>
<div class='leftwrap'>
<div class='left left1'>
<div class="image">My image here</div>
<div class="imagetext">Some text</div>
</div>
<div class='left left2'>
<div class="image">My image here</div>
<div class="imagetext">Some text</div>
</div>
</div>
<div class='right'>3</div>
</div>
I am working on a personal design project where I have 5 tiles with images in them and when you mouse over any of them they display alternate text. I have included my source code but my problem seems to be when I test this by hovering over the tile I added the W3 snippet to nothing happens. If I inspect the code however and add the hover attribute in the Chrome inspect tool it seems to work just fine. What am I missing here?
Here is my code My Code
.bottom p {
text-align: center;
}
.bottom {
margin-top: 200px;
width: 50%;
}
.top {
width: 33.33333333333%;
display: inline-block;
}
.tile {
height: 200px;
justify-content: center;
align-items: center;
overflow: hidden;
padding-left: 0px;
padding-right: 0px;
border-style: solid;
border-width: 5px;
border-color: /*Navy Blue*/ #333333/* FetchMe Orange #FBAA1E*/;
text-align: center;
box-shadow: 5px 5px 10px #000000;
}
.tile p {
z-index: 4;
font-size: 24px;
position: absolute;
bottom: 0;
margin-bottom: 10px;
font-weight: bold;
text-align: center;
margin-left: 35%;
margin-right: 35%;
}
.img1 {
flex-shrink: 0;
min-width: 100%;
min-height: 100%
}
.top p {
text-align: center;
}
.fetch-form {
padding-top: 50px;
padding-bottom: 50px;
margin: 0 auto;
position: absolute;
z-index: 3;
margin-left: 110px;
margin-right: 110px;
left: 0;
right: 0;
}
.tiles {
margin-left: 0px;
margin-right: 0px;
z-index: 2;
position: absolute;
top: 150px;
left: 0px;
color: white;
display: inline-block;
padding-top: 10px;
}
.inner {
display: block;
margin-left: auto;
margin-right: auto;
}
.slider {
z-index: -1;
position: absolute;
padding-right: 0;
padding-left: 0;
margin-right: 0;
margin-left: 0;
left: 0;
right: 0;
top: 0;
height: 600px;
min-width: 100%;
}
.item {
height: 600px;
}
.container {
position: relative;
}
.overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: #008CBA;
overflow: hidden;
width: 0%;
height: 100%;
transition: .5s ease;
z-index: 5;
}
.container:hover .overlay {
width: 100%;
}
.text {
white-space: nowrap;
color: white;
font-size: 20px;
position: absolute;
overflow: hidden;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
}
.image {
display: block;
width: 100%;
height: auto;
}
<div class="row">
<div class="col-xs-10 fetch-form">
<form action="order" method="POST" role="form" id="address_form">
<div class="col-xs-12 fetch-form">
<div class="row">
<div class="col-xs-8 input">
<div class="input">
<i class="icon-prepend fa fa-home"></i>
<input type="text" placeholder="Street Address (optional)" id="address" name="address" class="form-control input-lg" autocomplete="off">
</div>
</div>
<div class="col-xs-2">
<input type="hidden" name="zip_code"><input type="hidden" value="true" name="set_temp_address">
<button class="btn btn-primary btn-lg btn-block btn" type="submit">
<i class="fa fa-search"></i> Fetch Me Food!
</button>
</div>
</div>
</div>
<div class="row well well-sm" style="display: none;">
<div class="col-xs-4 text-center">
<div class="radio" >
<label><center><i class="fa fa-taxi fa-lg hidden-xs"> </i></center>
<input type="radio" id="type_delivery" name="order_type" value="DELIVERY" checked="checked">
<span class="radiosearch"> </span><span class="ordertype">Delivery</span>
</label>
</div>
</div>
<div class="col-xs-4 text-center border-left">
<div class="radio">
<label>
<center><i class="fa fa-cutlery fa-lg hidden-xs"> </i></center>
<input type="radio" id="type_takeout" name="order_type" value="TAKEOUT">
<span class="radiosearch"> </span>
<span class="ordertype"><nobr>Pick-up</nobr></span>
<nobr></nobr>
</label>
</div>
</div>
<div class="col-xs-4 text-center border-left" >
<div class="radio"><a href="/account/groups" style="color: #333333;">
<label>
<center><i class="fa fa-group fa-lg" style="margin-bottom: 6px;"> </i></center>
<span class="ordertype"><span style="margin-top:9px;" class="visible-xs">Group »</span></span> <span
class="ordertype"><span class="hidden-xs">Group Order »</span></span> </label></a></div>
</div>
</div>
</form>
</div>
<div class="col-xs-12 tiles">
<div class="inner">
<div class="col-xs-3 top tile container">
<p>Restarunts and Catering</p>
<img src="https://s3.amazonaws.com/fetchme-prototype/images/fruits-grocery-bananas-market.jpg" class="img1 image" alt="">
<div class="overlay">
<div class="text">Hello World</div>
</div>
</div>
</div>
<div class="col-xs-3 top tile">
<img src="https://s3.amazonaws.com/fetchme-prototype/images/fruits-grocery-bananas-market.jpg" class="img1" alt="">
<p>Our Deals</p>
</div>
<div class="col-xs-3 top tile">
<img src="https://s3.amazonaws.com/fetchme-prototype/images/fruits-grocery-bananas-market.jpg" class="img1" alt="">
<p>Grocery Shopping</p>
</div>
</div>
</div>
<br>
<div class="col-xs-12 tiles">
<div class="inner">
<div class="col-xs-6 bottom tile">
<img src="https://s3.amazonaws.com/fetchme-prototype/images/fruits-grocery-bananas-market.jpg" alt="" class="img1" >
<p>Tailgates</p>
</div>
<div class="col-xs-6 bottom tile">
<img src="https://s3.amazonaws.com/fetchme-prototype/images/fruits-grocery-bananas-market.jpg" alt="" class="img1">
<p>Order Anything</p>
</div>
</div>
</div>
<div class="slider col-xs-12">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<!-- Slide one -->
<div class="item active">
<img src="https://s3.amazonaws.com/fetchme-prototype/images/download.jpg" alt="">
</div>
<!-- Slide two -->
<div class="item">
<img src="https://s3.amazonaws.com/fetchme-prototype/images/download.jpg" alt="">
</div>
<!--Slide three -->
<div class="item">
<img src="https://s3.amazonaws.com/fetchme-prototype/images/download+(2).jpg" alt="">
</div>
<!--Slide four -->
<div class="item">
<img src="https://s3.amazonaws.com/fetchme-prototype/images/download+(2).jpg" alt="">
</div>
</div>
</div>
</div>
</div>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
This is an issue with other tiles overlapping the containers (z-index issue). You can try something like this:
.tiles {
pointer-events: none;
}
.container {
pointer-events: auto;
}
It is because you have used .tiles class for both .col-xs-12 items which are supposed to be 2 rows of pictures.
.tiles class has top, left properties defined and are position property as absolute. Since both rows of pictures have same top and left positions from .tiles, the second one overlaps the first.
This is why hover will never happen for .container normally. hover is always happening for the second row which is on top even though 1st row is visible below.
I have this div with a class of .win_box:
The div is surrounded by a Bootstrap column. The link is allowing the user to allow the link throughout the entire Bootstrap column itself. I only want users to have access to this link on the actual div itself. How do I do this?
.win_box {
position: relative;
left: -12px;
height: 110px;
width: 196px;
background: #353535;
}
<div class="col-xs-6 col-sm-6 col-md-2 col-lg-g" id='title'>
<a href='#'> <div class='win_box'> <i class="fa fa-play" aria-hidden="true" id='video'></i> </div> </a>
</div>
Add
display:inline-block;
to the .win_box class and you are good to go.
.win_box {
position: relative;
left: -12px;
height: 110px;
width: 196px;
background: #353535;
display:inline-block;
}
and you are good to go
You can do this using a display: inline-block;
.win_box {
position: relative;
left: -12px;
height: 110px;
width: 196px;
background: #353535;
display: inline-block;
}
<div class="col-xs-6 col-sm-6 col-md-2 col-lg-g" id='title'>
<div class='win_box' onClick="window.location='https://google.com';" > <i class="fa fa-play" aria-hidden="true" id='video'></i> </div> </a>
</div>
The other option is to use JS for linking. onclick="location.href='www.google.com'"
<div class="col-xs-6 col-sm-6 col-md-2 col-lg-g" id='title'>
<div class='win_box' onclick="location.href='www.google.com'"> <i class="fa fa-play" aria-hidden="true" id='video'></i> </div>
</div>
Fiddle - https://jsfiddle.net/6n2bpep4/2/
How would I make it so the banners along the top and bottom of this page (http://i.imgur.com/SxjbCJV.jpg) are instead at both sides of the page?
I currently have them both fixed to the top and bottom of the page:
#header {
position: fixed;
top: 0;
width: 100%;
height: 66px;
z-index: 999;
}
#footer {
position: fixed;
bottom: 0;
width: 100%;
height: 66px;
z-index: 999;
}
And the HTML:
<body>
<div id="wrapper">
<a href="project.html">
<div id="header">
<button id="next-button" href="project.html"><i class="fa fa-arrow-circle-right fa-4x"></i>
</button>
</div>
</a>
<div id="main">
<div id="splash">
<div id="name">
<h1 class="wow animated flipInX">Max Wilson</h1>
</div>
<div id="profile">
<img src="img/Logo.png" class="wow animated rollIn" data-wow-delay="1s">
</div>
<div id="subtext">
<h2 class="wow animated fadeInUp" data-wow-delay="2s">Aspiring Developer </h2>
</div>
</div>
</div>
</div>
<a href="project.html">
<div id="footer">
<button id="prev-button" href="project.html"><i class="fa fa-arrow-circle-left fa-4x"></i>
</button>
</div>
</a>
Have you tried floating the header and footer to the left?
For example:
#header {
position: relative;
float: left;
width: 50px;
height: 500px;
background-color: #44f;
}
#footer {
position: relative;
float: left;
width: 50px;
height: 500px;
background-color: #44f;
}
#wrapper{ text-align: center;
margin-left: auto;
margin-right: auto;
}
#main{ width: 800px;
float:left;
}
Here's a simple and interesting method: giving the body display: flex and the content flex-grow: 1 so it occupies all the available space and pins the other elements to either side.
<div class="side">
<h3>asdf</h3>
<h3>asdf</h3>
<h3>asdf</h3>
<h3>asdf</h3>
</div>
<div id="content">
<p>asdfasdf</p>
</div>
<div class="side">
<h3>asdf</h3>
<h3>asdf</h3>
<h3>asdf</h3>
<h3>asdf</h3>
</div>
body {
display: flex;
}
.side, #content {
padding: 10px;
}
.side {
background: blue;
}
#content {
flex-grow: 1;
background: grey;
}
https://jsfiddle.net/JackHasaKeyboard/rz86xwxh/2/