I need to create a fairly static page divided into regions with an image carousel on the right (hcentered and vcentered)
This needs to be very browser compatible, so flexbox is not really an option
Here is a mockup image of what I'm after:
Mockup
The Code I have thus far is as follows, but I can for the life of me not get the right hand image to be centered and middle aligned:
$(function() {
// var exits = ['fadeOut', 'fadeOutDown', 'fadeOutUpBig', 'bounceOut', 'bounceOutDown', 'hinge',
// 'bounceOutUp', 'bounceOutLeft', 'rotateOut', 'rotateOutUpLeft', 'lightSpeedOut', 'rollOut'];
// var entrances = ['fadeIn', 'fadeInDown', 'fadeInRight', 'bounceIn', 'bounceInRight', 'rotateIn',
// 'rotateInDownLeft', 'lightSpeedIn', 'rollIn', 'bounceInDown' ];
var exits = ['fadeOut'];
var entrances = ['fadeInRight'];
var photos = $('#photos'),
ignoreClicks = false;
$('.arrow').click(function(e, simulated) {
if (ignoreClicks) {
// If clicks on the arrows should be ignored,
// stop the event from triggering the rest
// of the handlers
e.stopImmediatePropagation();
return false;
}
// Otherwise allo this click to proceed,
// but raise the ignoreClicks flag
ignoreClicks = true;
if (!simulated) {
// Once the user clicks on the arrows,
// stop the automatic slideshow
clearInterval(slideshow);
}
});
// Listen for clicks on the next arrow
$('.arrow.next').click(function(e) {
e.preventDefault();
// The topmost element
var elem = $('#photos #innerdiv:last');
// Apply a random exit animation
elem.addClass('animated')
.addClass(exits[Math.floor(exits.length * Math.random())]);
setTimeout(function() {
// Reset the classes
elem.attr('class', '').prependTo(photos);
// The animation is complate!
// Allow clicks again:
ignoreClicks = false;
}, 10);
});
// Start an automatic slideshow
var slideshow = setInterval(function() {
// Simulate a click every 1.5 seconds
$('.arrow.next').trigger('click', [true]);
}, 1000);
});
/* https://tutorialzine.com/2013/02/animated-css3-photo-stack */
body {
/* overflow:hidden;*/
}
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
#photos {
/* margin:0 auto; */
/*position:relative; */
}
#photos .outerdiv {
position: relative;
}
#photos .middlediv {
/* position:absolute; */
/* display:inline-block; */
/* width:450px; */
/* height:450px; */
/* overflow:hidden; */
background-color: #fff;
z-index: 10;
border: 1px solid #aaa;
/* -webkit-animation-duration: 1s; */
-moz-animation-duration: 1s;
/* animation-duration: 1s; */
}
#photos .innerdiv {
/* position:absolute; */
/* top:0px; */
/* left:0px; */
/* right:0px; */
/* bottom:0px; */
width: 450px;
height: 450px;
background-size: cover;
background-position: center;
/*overflow:hidden;*/
/* width:400px; */
/* height:400px; */
position: absolute;
}
.lefttop {
grid-area: lefttop;
width: 50vw;
height: 33.3vh
}
.leftcenter {
grid-area: leftcenter;
width: 50vw;
height: 33.3vh
}
.leftbottom {
grid-area: leftbottom;
width: 50vw;
height: 33.3vh
}
.rightfull {
grid-area: rightfull;
width: 50vw;
}
.grid-container {
display: grid;
grid-template-areas: 'lefttop rightfull' 'leftcenter rightfull' 'leftbottom rightfull';
grid-gap: 1px;
background-color: #2196F3;
padding: 1px;
}
.grid-container>div {
background-color: rgba(255, 255, 255, 0.8);
text-align: center;
padding: 0px;
font-size: 30px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="grid-container">
<div class="lefttop">left top</div>
<div class="leftcenter">left center</div>
<div class="leftbottom">left bottom </div>
<div class="rightfull">
<div id="photos" class="outerdiv">
<div class="middlediv">
<div class="innerdiv" style="background-image:url(http://127.0.0.1:81/wordpress/wp-content/uploads/2018/08/20180823_132842-01-400x347.jpeg)"></div>
</div>
<div class="middlediv">
<div class="innerdiv" style="background-image:url(http://127.0.0.1:81/wordpress/wp-content/uploads/2018/07/20180806_162813-01-1-400x389.jpeg)"></div>
</div>
<div class="middlediv">
<div class="innerdiv" style="background-image:url(http://127.0.0.1:81/wordpress/wp-content/uploads/2018/08/20180820_153720-01-400x356.jpeg)"></div>
</div>
</div>
</div>
</div>
Ideally, I would want to use grid or table but it seems like table does not allow for vertical merging of cells.
IE10 and above needs to be supported.
The image in the carousel should be a percentage of the width or height of the right hand column to make it relatively responsive to different screen sizes.
I have used the photo carousel at https://tutorialzine.com/2013/02/animated-css3-photo-stack and modified the code and javascript slightly as I thought using divs would be easier than UL's and LI's, but the results are just about the same.
Any guidance on how to achieve this without too many dirty fixes would be very much appreciated!
In other words:
a simple page, divided into two equal columns.
The left column should have a logo and some links spaced vertically away from the middle horizontal line of the screen.
The right column should be half the screen width, and full screen height with the image carousel centered and middle of the column with responsive width and height.
here is a fiddle with your requirement, I was based on the mock image in your question, I hope this help you.
Here is the HTML:
<div class="grid-container">
<div class="lefttop">
<h1>
LOGO
</h1>
</div>
<div class="leftbottom">
<ul>
<li>
home
</li>
<li>
about
</li>
<li>
contact
</li>
</ul>
</div>
<div class="rightfull">
<div id="photos" class="outerdiv">
<div class="middlediv">
<img class="innerdiv" src="https://picsum.photos/200/300/?random">
</div>
<div class="middlediv">
<img class="innerdiv" src="https://picsum.photos/200/300/?random">
</div>
<div class="middlediv">
<img class="innerdiv" src="https://picsum.photos/200/300/?random">
</div>
</div>
</div>
</div>
And tht SCSS
/* https://tutorialzine.com/2013/02/animated-css3-photo-stack */
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
html, body {
height: 100%;
}
.grid-container {
overflow: hidden;
display: grid;
height: 100% !important;
grid-template-columns: repeat(2, 50%);
grid-template-rows: repeat(2, 50%);
background-color: #2196F3;
& > div {
background-color: rgba(255, 255, 255, 0.8);
text-align: center;
padding: 0px;
// font-size: 30px;
}
.lefttop, .leftbottom {
grid-column: 1;
}
.lefttop {
&::before, & > h1 {
display: inline-block;
vertical-align: bottom;
}
&::before {
content: '';
height: 100%;
}
grid-row: 1;
position: relative;
h1 {
font-size: 3rem;
font-weight: 100;
}
}
.leftbottom {
grid-row: 2;
ul {
margin: 1rem auto;
li {
list-style: none;
display: inline;
&:not(:first-child):not(:last-child)::before {
content: '-';
}
&:not(:first-child):not(:last-child)::after {
content: '-';
}
a {
text-decoration: none;
color: inherit;
}
}
}
}
.rightfull {
grid-column: 2 / 3;
grid-row: 1 / 3;
position: relative;
img {
top: 0;
left: 0;
padding: 1rem;
position: absolute;
width: 100%;
height: 100%;
object-fit: cover;
}
}
}
https://jsfiddle.net/cisco336/wpfzL03k/1/
Here is MS Edge screenshot
MS IE11 screenshot
Related
I have been asked to create an image gallery for a test website for a mini project at work with a few other people. I have created the gallery and the pop up images based on the code here: http://www.w3schools.com/howto/howto_css_modal_images.asp
The layout of the gallery itself is fine as there will be more images, but when I click on the images in the gallery, the images that pop up are all different sizes. We have been trying for a while now to give the images a fixed width and height to ensure that when they pop up they are all the same size and centred in the middle so that the user does not have to scroll up and down. Changing the width then results in the next and previous arrows being all over the place. We have made a few tweaks to the code but so far have been unable to get the desired result.
Can someone please point us in the right direction on how we can achieve this.
This is the code we have:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1">
<title>PRINTS</title>
<style>
body {font-family: Arial, Helvetica, sans-serif;}
/* Style the Image Used to Trigger the Modal */
* {
box-sizing: border-box;
margin: 0;
padding: 0 10px;
}
.image-container {
width: 100%;
height: 70%;
columns: 4;
}
.myImg {
border-radius: 5px;
cursor: pointer;
transition: 0.3s;
max-width: 100%;
padding: 1px;
}
.myImg:hover {opacity: 0.7;}
/* The Modal (background) */
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
padding-top: 100px; /* Location of the box */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.9); /* Black w/ opacity */
}
/* Modal Content (Image) */
.modal-content {
margin: auto;
padding: 0;
width: 90%;
max-width: 100px;
position: relative;
}
/* Add Animation - Zoom in the Modal */
.modal-content, #caption {
-webkit-animation-name: zoom;
-webkit-animation-duration: 0.6s;
animation-name: zoom;
animation-duration: 0.6s;
}
#-webkit-keyframes zoom {
from {-webkit-transform:scale(0)}
to {-webkit-transform:scale(1)}
}
#keyframes zoom {
from {transform:scale(0)}
to {transform:scale(1)}
}
/* The Close Button */
.close {
color: white;
position: absolute;
top: 10px;
right: 25px;
font-size: 35px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #999;
text-decoration: none;
cursor: pointer;
}
/* Hide the slides by default */
.mySlides {
display: none;
}
.image-wrapper {
position: absolute;
}
/* Next & previous buttons */
.prev,
.next {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
padding: 20px;
margin-top: -50px;
color: white;
font-weight: bold;
font-size: 20px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
user-select: none;
-webkit-user-select: none;
}
/* Position the "next button" to the right */
.next {
right: 0;
}
/* Number text (1/3 etc) */
.numbertext {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: absolute;
top: 0;
}
/* On hover, add a black background color with a little bit see-through */
.prev:hover,
.next:hover {
background-color: rgba(0, 0, 0, 0.8);
}
img.demo {
opacity: 0.6;
}
.active,
.demo:hover {
opacity: 1;
}
img.hover-shadow {
transition: 0.3s;
}
.hover-shadow:hover {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
/* Number text (1/3 etc) */
.numbertext {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: relative;
top: 0;
}
/* 100% Image Width on Smaller Screens */
#media only screen and (max-width: 700px){
.modal-content {
width: 100%;
}
}
</style>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Trigger the Modal -->
<div class="image-container">
<img class="myImg" src="https://images.unsplash.com/photo-1526512340740-9217d0159da9?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8dmVydGljYWx8ZW58MHx8MHx8&w=1000&q=80.jpg" onclick="openModal();currentSlide(1)" class="hover-shadow">
<img class="myImg" src="https://images.all-free-download.com/images/graphiclarge/bridge_holiday_horizontal_landscape_nature_nobody_603727.jpg" onclick="openModal();currentSlide(2)" class="hover-shadow">
<img class="myImg" src="https://cdn.fstoppers.com/styles/full/s3/photos/2019/02/857ebd7658e56c84a4dc65cc4453a305.jpg?itok=rpCL6_UU.jpg" onclick="openModal();currentSlide(3)" class="hover-shadow">
<img class="myImg" src="https://www.difrusciaphotography.com/wp-content/uploads/2015/04/The-Awakening_Moraine-Lake-Alberta-Canada_03.jpg" onclick="openModal();currentSlide(4)" class="hover-shadow">
<img class="myImg" src="https://www.jessleephotos.com/images/xl/overlook-autumn.jpg" onclick="openModal();currentSlide(5)" class="hover-shadow">
<img class="myImg" src="https://images.freeimages.com/images/small-previews/7cb/father-tree-1377206.jpg" onclick="openModal();currentSlide(6)" class="hover-shadow">
<img class="myImg" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQnERA1ahoVfRaMs2rPHKYlx-cUXeA8_N2DWA&usqp=CAU.jpg" onclick="openModal();currentSlide(7)" class="hover-shadow">
<img class="myImg" src="https://images.unsplash.com/photo-1506522167817-40236fa71038?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxjb2xsZWN0aW9uLXBhZ2V8M3wxMzc4NDI3fHxlbnwwfHx8fA%3D%3D&w=1000&q=80.jpg" onclick="openModal();currentSlide(8)" class="hover-shadow">
</div> <!-- end image-container div -->
<!-- The Modal -->
<div id="myModal" class="modal">
<span class="close cursor" onclick="closeModal()">×</span>
<div class="modal-content">
<div class="mySlides">
<div class="numbertext"> 1 / 46</div>
<img src="https://images.unsplash.com/photo-1526512340740-9217d0159da9?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8dmVydGljYWx8ZW58MHx8MHx8&w=1000&q=80.jpg">
</div>
<div class="mySlides">
<div class="numbertext"> 2 / 46</div>
<img src="https://images.all-free-download.com/images/graphiclarge/bridge_holiday_horizontal_landscape_nature_nobody_603727.jpg">
</div>
<div class="mySlides">
<div class="numbertext"> 3 / 46</div>
<img src="https://cdn.fstoppers.com/styles/full/s3/photos/2019/02/857ebd7658e56c84a4dc65cc4453a305.jpg?itok=rpCL6_UU.jpg">
</div>
<div class="mySlides">
<div class="numbertext"> 4 / 46</div>
<img src="https://www.difrusciaphotography.com/wp-content/uploads/2015/04/The-Awakening_Moraine-Lake-Alberta-Canada_03.jpg">
</div>
<div class="mySlides">
<div class="numbertext"> 5 / 46</div>
<img src="https://www.jessleephotos.com/images/xl/overlook-autumn.jpg">
</div>
<div class="mySlides">
<div class="numbertext"> 6 / 46</div>
<img src="https://images.freeimages.com/images/small-previews/7cb/father-tree-1377206.jpg">
</div>
<div class="mySlides">
<div class="numbertext"> 7 / 46</div>
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQnERA1ahoVfRaMs2rPHKYlx-cUXeA8_N2DWA&usqp=CAU.jpg">
</div>
<div class="mySlides">
<div class="numbertext"> 8 / 46</div>
<img src="https://images.unsplash.com/photo-1506522167817-40236fa71038?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxjb2xsZWN0aW9uLXBhZ2V8M3wxMzc4NDI3fHxlbnwwfHx8fA%3D%3D&w=1000&q=80.jpg">
</div>
<!-- Next/previous controls -->
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
</div>
<script>
function openModal() {
document.getElementById("myModal").style.display = "block";
}
function closeModal() {
document.getElementById("myModal").style.display = "none";
}
var slideIndex = 1;
showSlides(slideIndex);
function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("demo");
if (n > slides.length) {slideIndex = 1}
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
captionText.innerHTML = dots[slideIndex-1].alt;
}
</script>
</body>
</html>
Try setting a max height on your images, max-height: 90vh; for example. VH units are the height of the viewport, so the images won't ever be taller than 90% of the viewport height in this instance. Then you can set the image widths to have max-width: 100%; and the user won't need to scroll. Also change your .mySlides CSS when the slide is active to use display: flex; rather than display: block; to allow you to center the image easily.
Try this adding these updated CSS rules:
.modal-content {
width: 500px;
max-width: 100%;
}
.mySlides img {
max-height: 90vh;
max-width: 100%;
}
When slide is active:
.mySlides {
display: flex;
flex-direction: column;
}
I want to layout list items evenly across a vertical container. All items have the same height (the last one has padding).
Normally I would use flex, but here is the challenge: The container expands with a transition to its final height - which is exactly the size of all li items stacked up with no overlap. In other words, flex is not relevant since the container height will forever be <= height of each item * the number of items.
What I need, is for the items to always spread out evenly, overlapping each other while filling up the container (starting from a complete overlap until they finally are stacked as they would with no intervention).
Here is a sandbox link to the setup of the problem:
https://codesandbox.io/s/holy-water-uln898?file=/index.html
Would appreciate your help!
const expand = () => {
document.getElementsByTagName("ul")[0].classList.add("expanded");
lis = document.getElementsByTagName("li")
for (let i = 1; i < lis.length; i++){
lis[i].style.top= i*25 + "px"
lis[i].classList.add("expand");
}
};
ul {
padding: 0;
border: 3px solid;
height: calc(25px + 8px);
transition: height 2s;
position:relative;
}
ul.expanded {
height: calc((25px * 3) + 8px);
}
li {
list-style: none;
height: 25px;
position:absolute;
left:0;
top:0;
width:100%
}
li:last-child {
padding-bottom: 8px;
}
li.item1 {
background: red;
color: darkred;
}
li.item2 {
background: green;
color: darkgreen;
}
li.item3 {
background: yellow;
color: orange;
}
button {
position: absolute;
top: 150px;
}
li.expand{
transition:top 2s;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Static Template</title>
</head>
<body>
<ul>
<li class="item1">
item1
</li>
<li class="item2">
item2
</li>
<li class="item3">
item3
</li>
</ul>
<button onClick="expand();">Click</button>
</body>
</html>
You can accomplish this with a bunch of wrappers. The list items are wrapped in an item with 0 height. Flex won't stack all the 0-height elements on top of each other unless its height is also 0 (because we must justify-content: space-between to distribute them when height is greater than 0), so the inner flex container has a height of 0 when closed, and the outer visible container (with the border) just adds a single items-worth of height to flex-container. The javascript is only for the demo.
This only works if every item has a known, static height. Transitioning height to auto is not easy by itself, let alone after you throw in some fancy overlapping.
let fullHeight = true
const button = document.querySelector(".button")
const container = document.querySelector(".container-restraint")
button.addEventListener("click", e => {
if (fullHeight) container.className = "container-restraint closed"
else container.className = "container-restraint"
fullHeight = !fullHeight
})
.list-item {
height: 100px; /* ITEM-HEIGHT */
width: 200px; /* ITEM-WIDTH */
}
.item-1 { background-color: #ff000066; }
.item-2 { background-color: #00ff0066; }
.item-3 { background-color: #0000ff66; }
.item-4 { background-color: #ffff0066; }
.container-restraint {
height: 300px; /* ITEM-HEIGHT * (N_ITEMS - 1) */
width: 200px; /* ITEM-WIDTH */
display: flex;
flex-flow: column;
transition: height 3s;
overflow: visible;
justify-content: space-between;
}
.container-restraint.closed {
height: 0;
}
.expanding-container {
width: max-content;
border: 3px solid black;
overflow: hidden;
padding-bottom: 100px; /* ITEM_HEIGHT */
}
.wrapper {
height: 0;
overflow: visible;
padding: 0;
}
<button class="button">transition</button>
<div class="expanding-container">
<div class="container-restraint">
<div class="wrapper">
<div class="list-item item-1"></div>
</div>
<div class="wrapper">
<div class="list-item item-2"></div>
</div>
<div class="wrapper">
<div class="list-item item-3"></div>
</div>
<div class="wrapper">
<div class="list-item item-4"></div>
</div>
</div>
</div>
You could use position: absolute; and jQuery animations to achieve the overlapping effect, like this:
const expand = () => {
document.getElementsByTagName("ul")[0].classList.add("expanded");
$('li').each(function(index, li){
$(li).animate({
top: (index * 25) + 'px'
}, 2000);
});
};
ul {
padding: 0;
border: 3px solid;
height: calc(25px + 8px);
transition: height 2s;
position: relative;
}
ul.expanded {
height: calc((25px * 3) + 8px);
}
li {
list-style: none;
height: 25px;
position: absolute;
top: 0;
left: 0;
right: 0;
}
li:last-child {
padding-bottom: 8px;
}
li.item1 {
background: red;
color: darkred;
}
li.item2 {
background: green;
color: darkgreen;
}
li.item3 {
background: yellow;
color: orange;
}
button {
position: absolute;
top: 150px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul>
<li class="item1">
item1
</li>
<li class="item2">
item2
</li>
<li class="item3">
item3
</li>
</ul>
<button onClick="expand();">Click</button>
I'm trying create a portfolio web page where you can open up modals that resemble windows xp desktop apps. So the outer div has a background image of the outside boundary/border with the close button etc and the inside is another div which is my resume which should be scrollable but stay fixed inside the outer div.
Here's my code so far:
import React, { Component } from 'react';
import Draggable from 'react-draggable';
import './modal.css'
import res from '/Users/anthonychoi98/Documents/GitHub/portfolio/src/images/resumetemp.jpg';
class Modal extends Component {
displayInfo () {
switch(this.props.modalInfo) {
case 'Modal A':
return <div className="modal-info">This is Modal A</div>
case 'Modal B':
return(
<div className="resume-container">
<div className="modal-resume" style={{backgroundImage: `url('${res}')`}}>
</div>
</div>
);
default:
return null
}
}
closeModal = (e) => {
e.stopPropagation()
this.props.closeModal()
}
render(){
const divStyle = {
display: this.props.displayModal ? 'block' : 'none'
};
return (
<>
<div>
<Draggable
axis="both"
handle=".modal"
defaultPosition={{x: 0, y: 0}}
position={null}
grid={[25, 25]}
scale={1}
onStart={this.handleStart}
onDrag={this.handleDrag}
onStop={this.handleStop}>
<div
className="modal"
style={divStyle}>
<div className="modal-content"
onClick={ e => e.stopPropagation() }>
<span
className="close"
onClick={ this.closeModal }>x
</span>
<div class="modal-flex">
{this.displayInfo()}
</div>
</div>
</div>
</Draggable>
</div>
</>
);
}
}
export default Modal;
and heres the css:
/* MODAL */
/* Background effect. It covers the entire site */
.modal {
z-index: 1; /* Overlay effect: positioned over other containers */
width: 55%; /* Full width */
height: 90%; /* Full height */
top: 0;
left: 0;
overflow: hidden; /* Enable scroll if needed -> use auto */
}
/* Modal content */
.modal-content {
overflow-y: auto;
overflow-x: hidden;
background-color: white;
width: 100%; /* Width in proportion to its parent container*/
max-width: 640px; /* Max width where it stops expanding */
height: 100%; /* Height in proportion to its parent container */
margin: auto; /* Auto margin according to the element width */
padding: 10px;
/* border: 1px solid black; */
z-index: 1;
position: fixed;
border-radius:10px;
background-size: cover;
background-image: url('https://www.zwodnik.com/media/images/adobe-reader_windows.png')
}
/* Close button */
.close {
color: black;
float: right; /* Positioned to the right of the parent container whichever size it is */
float: top;
font-size: 30px !important;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
div.modal-flex {
/* overflow: auto; */
background-size: contain;
background-color: white;
width: 100%; /* Width in proportion to its parent container*/
height: 100%; /* Height in proportion to its parent container */
margin-top: 20px!important;
margin: auto;
border: 1px solid black;
z-index: 1;
overflow: contain;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
justify-content: flex-start;
align-content: center;
align-items: flex-start;
}
div.resume-container{
overflow: auto;
position: absolute;
}
div.modal-resume{
/* background-size: contain; */
margin-bottom:45px;
position: relative;
min-width: 100%;
min-height: 100%;
padding-bottom: 50px;
order: 0;
/* flex: 1 1 auto; */
align-self: stretch;
background-repeat: no-repeat;
/* background-image: url('/Users/anthonychoi98/Documents/GitHub/portfolio/src/images/resumetemp.jpg'); */
}
span.close{
padding-right:20px;
padding-bottom:35px;
margin-top:-8px;
}
Is there a better way to make this? I know it will probably look wrong on different sized screens or if the page is minimized/maximized. I could just photoshop the resume into the background but i would not be able to scroll
I wanted to create a navigation bar, at the top of my page, that would follow no matter what way you scroll.
I created it, and after that created a slideshow under it. The problem is, that everything related to my slideshow, will interrupt the navigation bar, when it scrolls through it, they overlap. I don't know how to fix this, and would like to get some help :)
CSS
/* HEADER - HEADER - HEADER */
/* Style the header */
.header {
background-color: lightgray;
padding: 20px;
text-align: center;
}
/* Style the top navigation bar */
.menu_navigation {
position: fixed;
overflow: hidden;
background-color: #333;
top: 0;
width: 100%;
}
/* Style the topnav links */
.menu_navigation a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 15px 25px;
text-decoration: none;
}
/* Change color on hover */
.menu_navigation a:hover {
background-color: rgb(0, 162, 255);
color: black;
}
/* Create three equal columns that floats next to each other */
.column {
float: left;
width: 33.33%;
padding: 10px;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - makes the three columns stack on top of each other instead of next to each other */
#media screen and (max-width:600px) {}
.column {
width: 100%;
}
* {box-sizing: border-box}
body {font-family: Verdana, sans-serif; margin:0}
.mySlides {display: none}
img {
vertical-align: auto;
position: relative;
top: 52px;
}
#billede1, #billede2, #billede3 {
filter: blur(8px);
}
/* Slideshow container */
.slideshow-container {
width: 1500;
}
/* Next & previous buttons */
.prev, .next {
position: absolute;
top: 50%;
width: auto;
padding: 16px;
margin-top: -22px;
color: white;
transition: 0.6s ease;
}
/* Position the "next button" to the right */
.next {
right: 0;
border-radius: 3px 0 0 3px;
}
/* On hover, add a black background color with a little bit see-through */
.prev:hover, .next:hover {
background-color: rgba(0,0,0,0.8);
}
/* Caption text */
.text {
color: #000000;
font-size: 30px;
padding: 8px 12px;
position: absolute;
bottom: -1200px;
width: 100%;
text-align: center;
}
/* Number text (1/3 etc) */
.numbertext {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: absolute;
top: 0;
}
/* The dots/bullets/indicators */
.dot {
cursor: pointer;
height: 15px;
width: 15px;
margin: 0 2px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
}
.active, .dot:hover {
background-color: #717171;
}
/* Fading animation */
.fade {
-webkit-animation-name: fade;
-webkit-animation-duration: 1.5s;
animation-name: fade;
animation-duration: 1.5s;
}
#-webkit-keyframes fade {
from {opacity: .4}
to {opacity: 1}
}
#keyframes fade {
from {opacity: .4}
to {opacity: 1}
}
/* On smaller screens, decrease text size */
#media only screen and (max-width: 300px) {
.prev, .next,.text {font-size: 11px}
}
.footer {
background-color:blue;
text-align: center;
padding: 10px;
}
html
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<body>
<div class="menu_navigation">
Men
Women
Children
About Us
News
</div>
<!-- Slideshow, for under navigationsbaren-->
<div class="slideshow-container">
<div class="mySlides fade">
<div class="numbertext">1 / 3</div>
<img src="C:\Users\Wahab\Desktop\hjemmesidenprojekt\billeder\1.jpg" id="billede1" style="width:100%" height="1000px">
<div class="text">Skjorte - 150 kr</div>
</div>
<div class="mySlides fade">
<div class="numbertext">2 / 3</div>
<img src="C:\Users\Wahab\Desktop\hjemmesidenprojekt\billeder\2.jpg" id="billede2" style="width:100%" height="1000px">
<div class="text">Mørke blå Chino bukser - 540 kr</div>
</div>
<div class="mySlides fade">
<div class="numbertext">3 / 3</div>
<img src="C:\Users\Wahab\Desktop\hjemmesidenprojekt\billeder\3.jpg" id="billede3" style="width:100%" height="1000px">
<div class="text">Hvide Chinos - 430 kr</div>
</div>
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
</div>
<br>
<div style="text-align:center">
<span class="dot" onclick="currentSlide(1)"></span>
<span class="dot" onclick="currentSlide(2)"></span>
<span class="dot" onclick="currentSlide(3)"></span>
</div>
<script>
var slideIndex = 1;
showSlides(slideIndex);
function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
if (n > slides.length) {slideIndex = 1}
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
}
</script>
</body>
</html>
You need to set the z-index of the navbar higher than any other z-index of any element.
The z-index provides a hierarchical structure of when elements are stacked amongst each other.
You can fix this by adding a z-index CSS property to your .menu_navigation class. The z-index property specifies the stack order of an element. An element with greater stack order is always in front of an element with a lower stack order.
.menu_navigation {
position: fixed;
overflow: hidden;
background-color: #333;
top: 0;
width: 100%;
z-index: 100;
}
The best way I can explain my question is by the picture I posted below. Basically when you increase the number of the width of an object it expands to the right(see figure 1), I know you can make it expand to the left by adding some changes to the css positioning, but I need my div to expand a little to the left and a little to the right to be able to take up a certain amount of space at a certain position.(See figure 2 below)What does happen (AKA the closest I can get):Figure 1:
What I want to happen (fill the whole area):
Figure 2:
so basically I want to know how I can achieve what is happening in figure 2
Try:
.div {
width: someWidth;
margin: 0 auto;
}
This can be achieved quite easy using flexbox.
Use align-items: flex-end; display: flex; and justify-content: center;in your parent element. Then define the child dimensions.
align-items: flex-end; : To vertically position the element at the end in the cross axis.
justify-content: center; : To horizontally center the element in the main axis.
JSFIDDLE
body {
margin: 0;
}
* {
box-sizing: border-box;
}
.flex-container {
align-items: flex-end;
display: flex;
justify-content: center;
height: 100vh;
border: .5em dashed black;
background-color: lightgreen;
}
.flex-item {
flex-basis: 3em;
height: 3em;
background-color: dodgerblue;
}
<div class="flex-container">
<div class="flex-item"></div>
</div>
EDIT:
Here's another demo for you to see how this behaves if you change the child element dimensions. (Click the blue square to toggle dimension change).
JSFIDDLE
$(".flex-item").on("click", function() {
$(this).toggleClass("flex-item--big");
});
body {
margin: 0;
}
* {
box-sizing: border-box;
}
.flex-container {
align-items: flex-end;
display: flex;
justify-content: center;
height: 100vh;
border: .5em dashed black;
background-color: lightgreen;
}
.flex-item {
flex-basis: 3em;
height: 3em;
background-color: dodgerblue;
transition: flex-basis 300ms linear, height 300ms linear;
cursor: pointer;
}
.flex-item--big {
flex-basis: 10em;
height: 10em;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="flex-container">
<div class="flex-item"></div>
</div>
EDIT 2:
After some specifications mentioned in the comments, here's what can be done.
To tweak "margin" between flex-items you would need to make this a
little bit more complex, wrapping each item in a container and adding
padding, which is not in the scope of the following demo.
Notes & Recommendations:
Try to avoid width and height changes in your elements, you should stick to transform and opacity in transitions and animations.
Try to make your transitions faster, something between 300ms and 500ms
DEMO
CODE SNIPPET:
function panels() {
/* jQuery Objects */
var $panelsContainer = $(".panels-container"),
$panel = $(".panel"),
/* Strings of Classes used */
cHasPanelOpened = "has-panel-opened",
cHoverEffect = "panel-hover-effect",
cOpened = "opened",
cLastClicked = "last-clicked",
cFaded = "faded";
/* Panel click event listener */
$panel.on("click", function() {
$panelsContainer
.toggleClass(cHasPanelOpened);
$(this)
.toggleClass([cHoverEffect, cOpened].join(" "))
.addClass(cLastClicked);
$panel.not(this)
.toggleClass(cFaded)
.removeClass(cLastClicked);
});
}
$(document).ready(panels);
body {
/* DEMO illustration purposes only */
margin: 0;
background-color: white;
border: .5em dotted darkorange;
height: 100vh;
/* DEMO illustration purposes only */
}
* {
box-sizing: border-box;
}
/*
Panels Container
*/
.panels-container {
display: flex;
//width: 460px;
//height: 290px;
/* DEMO illustration purposes only */
height: 100%;
transform: scale(.9);
/* DEMO illustration purposes only */
}
/*
Panel Sections
*/
.panel__section {
display: flex;
flex-flow: row wrap;
}
.panel__section--media {
flex-basis: 66%;
}
.panel__section--download {
flex-basis: 34%;
}
/*
Panel
*/
.panel {
position: relative;
transition: transform 300ms, opacity 500ms;
cursor: pointer;
}
.panel--blue {
flex-basis: 100%;
height: 50%;
background-color: #2196F3;
background-image: url('https://cdn2.scratch.mit.edu/get_image/user/15016755_60x60.png?v=1465352804.66');
background-size: 50% 100%;
transform-origin: top left;
}
.panel--red,
.panel--yellow {
flex-basis: 50%;
height: 50%;
align-self: flex-end;
}
.panel--red {
background: url('http://iconshow.me/media/images/Application/Modern-Flat-style-Icons/png/512/Video.png') #F44336 no-repeat center;
background-size: 120px;
transform-origin: bottom left;
}
.panel--yellow {
background: url('https://scontent.cdninstagram.com/t51.2885-15/s320x320/e15/10731543_602219616549530_1911663388_n.jpg?ig_cache_key=ODQxODcxMTQxNDcxOTE1NzQw.2') #FFEB3B no-repeat center;
background-size: 100%;
transform-origin: center bottom;
}
.panel--green {
flex-basis: 100%;
height: 100%;
background: url('https://cdn1.iconfinder.com/data/icons/hawcons/32/698860-icon-129-cloud-download-128.png') #4CAF50 no-repeat center;
transform-origin: center right;
}
/*
Handle each panel when opened
*/
.panel--blue.opened {
transform: scale(calc(1/.66), 2);
}
.panel--green.opened {
transform: scaleX(calc(1/.34));
background-size: 50% 50%;
}
.panel--red.opened {
transform: scale(calc(1/.33), 2);
}
.panel--yellow.opened {
transform: scale(calc(1/.33), 2);
}
/*
Styling Helpers
*/
.faded {
opacity: 0;
}
.opened {
outline: 0;
}
.last-clicked {
z-index: 1;
}
.panel-hover-effect:hover {
transform: skewY(3deg);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Panel Section Begin -->
<section class="panels-container">
<section class="panel__section panel__section--media">
<div class="panel panel--blue panel-hover-effect"></div>
<div class="panel panel--red panel-hover-effect"></div>
<div class="panel panel--yellow panel-hover-effect"></div>
</section>
<section class="panel__section panel__section--download">
<div class="panel panel--green panel-hover-effect"></div>
</section>
</section>
<!-- Panel Section End -->
You can read more about flexbox here.