I've created a box containing images, but what I am trying to do is:
either display the images inline or position them on top of each other, then navigate among them using JQuery.
I've tried absolute positioning on both .box and .box img as well as display: inline but they mess up the code.
here it is so far:
.box {
position: absolute;
left: 10%;
width: 80%;
border: 10px solid white;
border-radius: 10px;
box-shadow: 0 0 4px black;
}
.box img {
width: 100%;
}
.prev, .next {
border: 1px solid black;
padding: 5px;
}
.prev:Hover, .next:Hover {
background-color: red;
color: white;
text-decoration: none;
}
<div class="container-fluid">
<h1>Welcome Within</h1>
<div class="box">
<img src="http://www.dan-dare.org/FreeFun/Images/PrinceOfPersiaWallpaper21024.jpg" />
<img src="https://www.gamewallpapers.com/img_script/mobile_dir2/img.php?src=wallpaper_prince_of_persia_warrior_within_18_ipad.jpg&height=755&width=850&crop-to-fit" />
<img src="https://r.mprd.se/media/images/66295-Prince_Of_Persia_Warrior_Within_READNFO-4.jpg" />
<br /></br />
PREVIOUS
NEXT
</div>
</div>
Try this:
.box {
position: absolute;
left: 10%;
width: 80%;
border: 10px solid white;
border-radius: 10px;
box-shadow: 0 0 4px black;
height: 300px;
overflow: hidden;
margin-bottom: 10px;
}
.caption {
position: absolute;
top: 10px;
color: red;
font-size: 20px;
background: #fff;
left: 30%;
}
.box img {
width: 100%;
}
.prev,
.next {
border: 1px solid black;
padding: 5px;
}
.prev:Hover,
.next:Hover {
background-color: red;
color: white;
text-decoration: none;
}
<div class="container-fluid">
<h1>Welcome Within</h1>
<div class="slider">
PREVIOUS
NEXT
<div class="box">
<img src="http://www.dan-dare.org/FreeFun/Images/PrinceOfPersiaWallpaper21024.jpg" />
<p class="caption">Caption1</p>
</div>
<div class="box">
<img src="https://www.gamewallpapers.com/img_script/mobile_dir2/img.php?src=wallpaper_prince_of_persia_warrior_within_18_ipad.jpg&height=755&width=850&crop-to-fit" />
<p class="caption">Caption2</p>
</div>
<div class="box">
<img src="https://r.mprd.se/media/images/66295-Prince_Of_Persia_Warrior_Within_READNFO-4.jpg" />
<p class="caption">Caption3</p>
</div>
</div>
</div>
I've tried this:
$(document).ready(function() {
$('.lightbox').click(function() {
$('.backdrop, .box').animate({
'opacity': '.50'
}, 300, 'linear');
$('.box').animate({
'opacity': '1.00'
}, 300, 'linear');
$('.backdrop, .box').css('display', 'block');
});
$('.close').click(function() {
close_box();
});
$('.backdrop').click(function() {
close_box();
});
//SlideShow
$('.next').click(function(){
clickNext();
});
$('.prev').click(function(){
clickPrev();
});
});
function close_box() {
$('.backdrop, .box').animate({
'opacity': '0'
}, 300, 'linear', function() {
$('.backdrop, .box').css('display', 'none');
});
}
//PREVIOUS
function clickPrev() {
$('.img_1').css('display', 'block');
//Move to the prev Image
$('.img_2').css('display', 'none');
}
//NEXT
function clickNext() {
$('.img_1').css('display', 'none');
//Move to the next Image
$('.img_2').css('display', 'block');
}
body {
font-family: Helvetica, Arial;
}
.backdrop {
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background: #000;
opacity: .0;
filter: alpha(opacity=0);
z-index: 50;
display: none;
}
.box {
position: absolute;
top: 50%;
transform: translate(-50%,-50%);
left: 50%;
background: white;
text-align: left;
z-index: 51;
padding: 0;
margin: 0;
display: none;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow: 0px 0px 5px #444444;
-webkit-box-shadow: 0px 0px 5px #444444;
box-shadow: 0px 0px 5px #444444;
border: 10px solid #fff;
width: 44%;
}
.box img {
width: 100%;
}
.box img:nth-child(2) {
display: none;
}
.caption {
padding-top: 10px;
font-size: 15px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container-fluid">
<h1>Welcome Within</h1>
Open Lightbox
<div class="backdrop"></div>
<div class="box">
<img class="img_1" src="http://www.dan-dare.org/FreeFun/Images/PrinceOfPersiaWallpaper21024.jpg" />
<img class="img_2" src="https://www.gamewallpapers.com/img_script/mobile_dir2/img.php?src=wallpaper_prince_of_persia_warrior_within_18_ipad.jpg&height=755&width=850&crop-to-fit" />
<div class="caption">
<p>This thing is called 'Caption'...Feels nice. Let me tell you:</p>
<hr />
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
PREVIOUS
NEXT
</div>
</div>
Related
I'm trying to practice my beginner html and CSS knowledge by making this template
https://www.w3schools.com/w3css/tryw3css_templates_band.htm
but the problem is when hitting inspect and reducing the width of the screen to see how my page looks like, I noticed that the div with the picture is getting smaller (which should as per the original one) but the div after it with the text (the one in green) is getting further away from it.
Is there a way to stop this from happening?
P.S. I made the div with the text in green to distinguish it for now only and the font awesome icons may not appear cuz I couldn't add the relevant CSS file of it here.
here is my page so far
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Band</title>
<!-- google fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lato:ital,wght#0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap" rel="stylesheet">
<style>
* {
box-sizing: border-box;
}
:root {
--main-padding: 20px;
}
html {
scroll-behavior: smooth;
}
body {
font-family: 'Lato', sans-serif;
}
/* start of nav bar */
nav {
background-color: black;
color: white;
position: fixed;
z-index: 99999;
width: 100%;
top: 0;
left: 0;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
}
nav ul li,
nav i {
cursor: pointer;
padding: 15px 20px;
}
nav ul li:hover {
background-color: lightgray;
color: black;
}
nav ul li:hover a {
color: black;
}
nav ul li a {
color: white;
text-decoration: none;
}
.ddmenu {
position: relative;
}
.ddmenu::after {
content: "";
position: absolute;
border: 5px solid;
border-color: white transparent transparent transparent;
right: 5px;
top: 50%;
}
.ddmenu:hover::after {
border-color: black transparent transparent transparent;
}
.ddmenu ul {
display: none;
background-color: white;
position: absolute;
top: 100%;
left: 0;
}
.ddmenu:hover ul {
display: block;
}
.fa-magnifying-glass:hover {
background-color: tomato;
}
i.fa-bars {
display: none;
}
#media (max-width:600px) {
i.fa-magnifying-glass,
li:not(.home) {
display: none;
}
i.fa-bars {
display: block
}
i.fa-bars:hover {
background-color: lightgray;
color: black;
}
}
/* end of nav bar */
/* start of posters */
.posters {
padding: 0;
color: white;
text-align: center;
position: relative;
margin-top: 48px;
margin-bottom: 0;
height: 100vh;
}
.posters .container {
position: absolute;
top: 0;
left: 0;
width: 100%;
animation-duration: 12s;
animation-iteration-count: infinite;
}
.posters .container:first-of-type {
animation-name: la;
}
#keyframes la {
0% {
z-index: 1;
}
33% {
z-index: 1;
}
34% {
z-index: 0;
}
}
.posters .container:nth-of-type(2) {
animation-name: ny;
}
#keyframes ny {
0% {
z-index: 0;
}
33% {
z-index: 0;
}
34% {
z-index: 1;
}
67% {
z-index: 1;
}
68% {
z-index: 0;
}
}
.posters .container:last-of-type {
animation-name: chicago;
}
#keyframes chicago {
0% {
z-index: 0;
}
67% {
z-index: 0;
}
68% {
z-index: 1;
}
}
.posters .container>div {
position: relative;
height: 100%;
}
.posters .container>div img {
width: 100%;
height: inherit;
}
.posters .container>div .text {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
-webkit-transform: translateX(-50%);
-moz-transform: translateX(-50%);
-ms-transform: translateX(-50%);
-o-transform: translateX(-50%);
padding-bottom: var(--main-padding);
}
.posters .container>div .text h4 {
font-size: 25px;
font-weight: normal;
}
.posters .container>div .text p {
font-weight: bold;
}
#media (max-width:600px) {
.posters .container>div .text {
display: none;
}
}
/* end of posters */
/* start of band */
section#band {
padding: var(--main-padding);
width: 100%;
background-color: green;
margin-top: 0;
}
#band .container {
padding: var(--main-padding);
width: 70%;
margin: auto;
background-color: lightgreen;
text-align: center;
}
#band .text h3 {
font-size: 30px;
font-weight: normal;
letter-spacing: 3px;
}
#band .text p:first-of-type {
color: grey;
}
#band .text p:nth-of-type(2) {
text-align: left;
}
.name {
max-width: 100%;
display: flex;
justify-content: space-between;
margin-top: 20px;
margin-bottom: 20px;
padding: var(--main-padding);
}
.name img {
max-width: 90%;
}
#media (max-width:600px) {
.name {
flex-direction: column;
}
}
/* end of band */
</style>
</head>
<body>
<!-- Nav Bar -->
<nav>
<ul>
<li class="home">HOME</li>
<li>BAND</li>
<li>TOUR</li>
<li>CONTACT</li>
<li class="ddmenu">MORE
<ul>
<li>Merchandise</li>
<li>Extras</li>
<li>Media</li>
</ul>
</li>
</ul>
<i class="fa-solid fa-magnifying-glass"></i>
<i class="fa-solid fa-bars"></i>
</nav>
<!-- posters -->
<section class="posters">
<div class="container">
<div class="la">
<img src="https://www.w3schools.com/w3images/la.jpg" alt="">
<div class="text">
<h4>Los Angeles</h4>
<p>We had the best time playing at Venice Beach!</p>
</div>
</div>
</div>
<div class="container">
<div class="ny">
<img src="https://www.w3schools.com/w3images/ny.jpg" alt="">
<div class="text">
<h4>New York</h4>
<p>The atmosphere in New York is lorem ipsum.</p>
</div>
</div>
</div>
<div class="container">
<div class="chicago">
<img src="https://www.w3schools.com/w3images/chicago.jpg" alt="">
<div class="text">
<h4>Chicago</h4>
<p>Thank you, Chicago - A night we won't forget.</p>
</div>
</div>
</div>
</section>
<!-- band info -->
<section id="band">
<div class="container">
<div class="text">
<h3>THE BAND</h3>
<p><i>We love music</i></p>
<p>We have created a fictional band website. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum consectetur
adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
<div class="name">
<div>
<p>Name</p>
<img src="https://www.w3schools.com/w3images/bandmember.jpg" alt="">
</div>
<div>
<p>Name</p>
<img src="https://www.w3schools.com/w3images/bandmember.jpg" alt="">
</div>
<div>
<p>Name</p>
<img src="https://www.w3schools.com/w3images/bandmember.jpg" alt="">
</div>
</div>
</div>
</section>
</body>
</html>
This was a little weird to fix due to the absolute positioning -- I've made it so that the poster is always 100% viewport height and the image will cover the whole poster -- your issue was that the image was shrinking to fit the width leaving a bunch of empty space below it
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Band</title>
<!-- google fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lato:ital,wght#0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap" rel="stylesheet">
<style>
* {
box-sizing: border-box;
}
:root {
--main-padding: 20px;
}
html {
scroll-behavior: smooth;
}
body {
font-family: 'Lato', sans-serif;
}
/* start of nav bar */
nav {
background-color: black;
color: white;
position: fixed;
z-index: 99999;
width: 100%;
top: 0;
left: 0;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
}
nav ul li,
nav i {
cursor: pointer;
padding: 15px 20px;
}
nav ul li:hover {
background-color: lightgray;
color: black;
}
nav ul li:hover a {
color: black;
}
nav ul li a {
color: white;
text-decoration: none;
}
.ddmenu {
position: relative;
}
.ddmenu::after {
content: "";
position: absolute;
border: 5px solid;
border-color: white transparent transparent transparent;
right: 5px;
top: 50%;
}
.ddmenu:hover::after {
border-color: black transparent transparent transparent;
}
.ddmenu ul {
display: none;
background-color: white;
position: absolute;
top: 100%;
left: 0;
}
.ddmenu:hover ul {
display: block;
}
.fa-magnifying-glass:hover {
background-color: tomato;
}
i.fa-bars {
display: none;
}
#media (max-width:600px) {
i.fa-magnifying-glass,
li:not(.home) {
display: none;
}
i.fa-bars {
display: block
}
i.fa-bars:hover {
background-color: lightgray;
color: black;
}
}
/* end of nav bar */
/* start of posters */
.posters {
padding: 0;
color: white;
text-align: center;
position: relative;
margin-top: 48px;
margin-bottom: 0;
height: calc(100vh - 48px);
min-height: 300px;
}
.posters .container {
position: absolute;
inset: 0;
animation-duration: 12s;
animation-iteration-count: infinite;
}
.posters .container:first-of-type {
animation-name: la;
}
#keyframes la {
0% {
z-index: 1;
}
33% {
z-index: 1;
}
34% {
z-index: 0;
}
}
.posters .container:nth-of-type(2) {
animation-name: ny;
}
#keyframes ny {
0% {
z-index: 0;
}
33% {
z-index: 0;
}
34% {
z-index: 1;
}
67% {
z-index: 1;
}
68% {
z-index: 0;
}
}
.posters .container:last-of-type {
animation-name: chicago;
}
#keyframes chicago {
0% {
z-index: 0;
}
67% {
z-index: 0;
}
68% {
z-index: 1;
}
}
.posters .container>div {
position: relative;
height: 100%;
overflow: hidden;
}
.posters .container>div img {
min-width: 100%;
min-height: 100%;
object-fit: cover;
position: relative;
left: 50%;
top: 50%;
transform: translate( -50%, -50% );
}
.posters .container>div .text {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%) translateY(calc(var(--main-padding) * -1));
}
.posters .container>div .text h4 {
font-size: 25px;
font-weight: normal;
}
.posters .container>div .text p {
font-weight: bold;
}
#media (max-width:600px) {
.posters .container>div .text {
display: none;
}
}
/* end of posters */
/* start of band */
section#band {
padding: var(--main-padding);
width: 100%;
background-color: green;
margin-top: 0;
}
#band .container {
padding: var(--main-padding);
width: 70%;
margin: auto;
background-color: lightgreen;
text-align: center;
}
#band .text h3 {
font-size: 30px;
font-weight: normal;
letter-spacing: 3px;
}
#band .text p:first-of-type {
color: grey;
}
#band .text p:nth-of-type(2) {
text-align: left;
}
.name {
max-width: 100%;
display: flex;
justify-content: space-between;
margin-top: 20px;
margin-bottom: 20px;
padding: var(--main-padding);
}
.name img {
max-width: 90%;
}
#media (max-width:600px) {
.name {
flex-direction: column;
}
}
/* end of band */
</style>
</head>
<body>
<!-- Nav Bar -->
<nav>
<ul>
<li class="home">HOME</li>
<li>BAND</li>
<li>TOUR</li>
<li>CONTACT</li>
<li class="ddmenu">MORE
<ul>
<li>Merchandise</li>
<li>Extras</li>
<li>Media</li>
</ul>
</li>
</ul>
<i class="fa-solid fa-magnifying-glass"></i>
<i class="fa-solid fa-bars"></i>
</nav>
<!-- posters -->
<section class="posters">
<div class="container">
<div class="la">
<img src="https://www.w3schools.com/w3images/la.jpg" alt="">
<div class="text">
<h4>Los Angeles</h4>
<p>We had the best time playing at Venice Beach!</p>
</div>
</div>
</div>
<div class="container">
<div class="ny">
<img src="https://www.w3schools.com/w3images/ny.jpg" alt="">
<div class="text">
<h4>New York</h4>
<p>The atmosphere in New York is lorem ipsum.</p>
</div>
</div>
</div>
<div class="container">
<div class="chicago">
<img src="https://www.w3schools.com/w3images/chicago.jpg" alt="">
<div class="text">
<h4>Chicago</h4>
<p>Thank you, Chicago - A night we won't forget.</p>
</div>
</div>
</div>
</section>
<!-- band info -->
<section id="band">
<div class="container">
<div class="text">
<h3>THE BAND</h3>
<p><i>We love music</i></p>
<p>We have created a fictional band website. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum consectetur
adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
<div class="name">
<div>
<p>Name</p>
<img src="https://www.w3schools.com/w3images/bandmember.jpg" alt="">
</div>
<div>
<p>Name</p>
<img src="https://www.w3schools.com/w3images/bandmember.jpg" alt="">
</div>
<div>
<p>Name</p>
<img src="https://www.w3schools.com/w3images/bandmember.jpg" alt="">
</div>
</div>
</div>
</section>
</body>
</html>
I'm trying to place an image in a circle div that's placed above a section containing text like in the image shown:
How can this be done using CSS? Thank you.
Run the Code Here
https://www.w3schools.com/code/tryit.asp?filename=GHOLRSYI9PEK
.flex-wrapper{
background-color: lightgray;
padding: 30px;
padding: 30px 30px 30px 100px;
}
.flex-container {
display: flex;
background-color: #f1f1f1;
}
.flex-container > div {
margin: 10px;
padding: 10px;
font-size: 16px;
}
.flex-container{
-webkit-box-shadow: 0 0 10px 1px rgba(0,0,0,0.2);
-moz-box-shadow: 0 0 10px 1px rgba(0,0,0,0.2);
box-shadow: 0 0 10px 1px rgba(0,0,0,0.2);
}
.avatar-wrapper{
min-width: 150px;
position: relative;
margin-left: -50px !important;
margin: 10px;
padding: 10px;
font-size: 16px;
height: 150px;
display: flex;
align-items: center;
justify-content: center;
}
.avatar-wrapper:after{
content: '';
height: calc(100% + 40px);
width: calc(100% + 40px);
position: absolute;
background: purple;
top: -20px;
left: -20px;
border-radius: 50%;
z-index: 0;
}
.avatar-wrapper > img{
width: 150px;
height: 150px;
z-index: 1;
position: relative;
border-radius: 50%;
}
<div class="flex-wrapper">
<div class="flex-container">
<div class="col avatar-wrapper">
<img src="https://via.placeholder.com/200" alt="sample">
</div>
<div class="col text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur</div>
</div>
</div>
img{ border-radius:50%; z-index:1 }
.container{
z-index:0;
margin-left:-100px;
box-shadow: 0px 0px 10px 1px lightgrey;
padding:5px;
width:50%;
}
.text{
text-decoration:underline blue;
margin-left:100px;
}
<div style="display:flex;">
<img src="https://via.placeholder.com/250">
<div class="container">
<div class="text">
I'm trying to place an image in a circle div that's placed above a section containing text like in the image shown:
</div>
</div>
</div>
Here is your solution. Just add your Image url in img tag
I'm not entirely sure how to phrase this question, but I'll give it a try.
I have a website set up with a side navigation menu. When the menu is opened, the body content is pushed all the way off screen making the text unreadable. I want to know what css property I need to set to make the text overflow onto the next line.
An example of this can be seen in the W3Schools. When the menu is opened, the text does not disappear behind the screen.
CSS
html,
body {
height: 100%;
font-family: 'Ubuntu', sans-serif;
}
body {
padding-top: 70px;
}
body.push {
overflow-x: hidden;
}
p {
color: red;
word-wrap: break-word;
}
.navbar-custom {
border-radius: 0;
transition: margin-left 0.5s;
transition: 0.5s;
padding-bottom: 6px;
background-color: transparent;
border-bottom: 1px solid #e5e5e5;
}
.navbar-custom a {
transition: 0.5s;
color: black;
}
.navbar-custom.color {
background-color: white;
}
.navbar-custom.color a {
color: black;
}
.navbar-custom.push {
margin-left: 300px;
background-color: white;
border-bottom: 1px solid #e5e5e5;
}
.navbar-custom.push a {
color: black;
}
.row {
text-align: center;
}
#main {
padding-top: 50px;
transition: margin-left 0.5s;
}
#main.push {
margin-left: 300px;
}
#sidenav {
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
left: 0;
overflow-x: hidden;
overflow-y: auto;
padding-top: 40px;
transition: 0.5s;
font-size: 15px;
background-color: white;
}
#sidenav li {
border-bottom: 1px solid #e5e5e5;
}
#sidenav a {
padding: 15px 8px 20px 32px;
text-decoration: none;
color: #818181;
display: block;
transition: 0.3s;
}
#sidenav i {
padding: 15px 8px 20px 10px;
text-decoration: none;
display: inline;
overflow-x: hidden;
}
#sidenav a:hover,
#sidenav .offcanvas a:focus {
text-decoration: none;
color: #ffcc00;
}
#sidenav .social {
text-align: center;
padding: 15px 8px 20px 32px;
}
#sidenav .social i:hover {
transition: 0.3s;
color: #ffcc00;
}
#sidenav #nav {
position: absolute;
top: 0;
width: 300px;
margin: 0;
padding: 0;
list-style: none;
}
#sidenav.toggled {
width: 300px;
border-right: 1px solid #e5e5e5;
}
#media screen and (max-height: 450px) {
#sidenav {
padding-top: 15px;
}
#sidenav a {
font-size: 18px;
}
}
#media screen and (max-width: 500px) {
#main.push {
margin-left: 200px;
}
#sidenav .social {
text-align: left;
}
#sidenav.toggled {
width: 200px;
}
.navbar-custom.push {
margin-left: 200px;
}
}
HTML
<section id="sidenav">
<ul id="nav">
<li class="social">
<i class="fa fa-envelope"><a href="#" class="hidden-sm hidden-md hidden-lg"><span
class="fa fa-envelope"></span></a></i>
<i class="fa fa-github"><a target="_blank" href="#" class="hidden-sm hidden-md hidden-lg"><span
class="fa fa-github"></span></a></i>
<i class="fa fa-linkedin"><a target="_blank" href="#"
class="hidden-sm hidden-md hidden-lg"><span class="fa fa-linkedin"></span></a></i>
</li>
<li>Home <span class="glyphicon glyphicon-home"></span></li>
<li>Portfolio <span class="fa fa-folder-open"></span></li>
<li><a target="_blank" href="#">Resume <span class="fa fa-file"></span> </a>
</li>
</ul>
</section>
<nav class="navbar navbar-custom navbar-fixed-top">
<section class="container">
<section class="navbar-header">
<a onclick="toggleMenu()" class="navbar-brand">Menu <i class="fa fa-bars" aria-hidden="true"></i></a>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</section>
</section>
</nav>
<section id="main">
<section class="container">
<p>
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
</p>
</section>
</section>
JS
var main = $("#main");
var sidenav = $("#sidenav");
var body = $("body");
var navbarFixed = $(".navbar-fixed-top");
var navbar = $(".navbar-custom");
function toggleMenu() {
main.toggleClass("push");
sidenav.toggleClass("toggled");
body.toggleClass("push");
navbarFixed.toggleClass("push");
};
I want to use css to crop a square image like seen on the attached image. But also using the text on the right so how would I realize that whole container?
<div style="width:100%">
<div style="widht:50%; float:left">
My Texting
</div>
<div style="widht:50%; float:left">
<img src="myimage.png">
</div>
</div>
See fiddle here: https://jsfiddle.net/hgo62n6a/ How to crop the image?
Solution is here (edited, much cleaner now and flexible):
DEMO: jsFiddle
HTML:
<div class='section clearfix'>
<div class='section-content section-col section-col-left'>
<div class='padding'>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div> <!-- end of .section-content -->
<div class='section-bar clearfix'>
<table>
<tr>
<td><a href=''>item 1</a></td>
<td><a href=''>item 2</a></td>
<td><a href=''>item 3</a></td>
</tr>
</table>
</div> <!-- end of .section-bar -->
<div class='section-bg' style='background-image: url("http://www.ysecit.com/css/images/bg-original.jpg")'> </div>
CSS:
*{
padding: 0;
margin: 0;
text-decoration: none;
box-sizing: border-box
}
.clearfix {
display: table;
}
.clarfix ::after{
content: "";
display: block;
clear: both;
}
.padding{
padding: 40px;
}
.section {
position:relative;
overflow: hidden;
}
.section-col{
}
.section-col-left {
float: left
}
.section-content {
width: 50%;
left: 0;
z-index: 3;
position: relative;
}
.section-content::before {
display: block;
width: 0;
content: "";
position: absolute;
top: 0;
right: -40px;
border: 1000px solid #fff;
border-right: 200px solid transparent;
z-index: 2;
}
.section-content div {
position: relative;
z-index: 3;
}
.section-bg {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-size: cover;
background-position: top right;
background-repeat: no-repeat;
}
.section-bar {
position: absolute;
bottom: 0;
width: 100%;
background: #000;
z-index: 2
}
.section-bar table {
float: right;
}
.section-bar table tr td {
padding: 10px
}
.section-bar table tr td a{
color: #fff
}
Use this CSS:
img {
position: absolute;
clip: rect(0px,60px,200px,0px);
}
The format for the clip attribute is as follows:
clip: rect(top, right, bottom, left);
please refer this one:
.holder {
width: 200px;
height: 200px
}
.holder:before {
content:"";
width: 0px;
height: 0px;
border-top: 20px solid transparent;
border-left: 20px solid transparent;
border-right: 20px solid white;
border-bottom: 20px solid white;
position:absolute;
top: 169px;
left: 169px;
}
img {
width: 100%;
height: 100%;
}
DEMO
Hope this will help you..
Here is Html code:
<div style="width:100%">
<div style="widht:50%;float:left;
background-color:#efefef;
height:200px
;width:300px;" class="cutCorner">
My Texting
</div>
<div style="widht:50%; float:left;" >
<img style=height:200px;width:300px;"
src="http://www.mobilo-med.de/uploads/media/Push_up_girl.jpg">
</div>
</div>
Css Code:
.cutCorner {
position:relative;
border:1px solid transparent; display: inline-block;
}
.cutCorner img {
display:block;
}
.cutCorner:after {
position:absolute; left:-2px; top:-2px; content:'';
border-bottom: 310px solid white;
border-left: 310px solid transparent;
}
https://jsfiddle.net/Harpreet_devgun/hgo62n6a/12/
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
i am making a website and i have noticed that i cannot scroll using the scroll wheel on a mouse. I can use two-finger scrolling on my chromebook but not the scroll wheel on my pc. The issue is with both of the browsers i use; firefox and chrome.
Thanks in advance, Liam
css:
header {
width: 100%;
}
body {
margin: 0;
overflow: hidden;
}
footer {
clear: both;
height: 100px;
width: 100%;
background-color: #3d3d3d;
position: relative;
}
.nav {
width: 100%;
height: 50px;
background-color: #3D3D3D;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0)
}
.navwrap{
position: fixed;
width: 100%;
}
.name-logo {
width: 100%;
height: 350px;
background-color: #4BD150;
overflow: hidden;
}
.content {
float: left;
background-color: #f5fafa;
padding-left: 3%;
padding-right: 2%;
border-right: 4px solid #F5f5f5;
width: calc(65% - 4px);
z-index: 1;
height: 300px;
}
.sidebar {
width: 30%;
float: right;
background-color: #f5fafa;
height: 300px;
}
.social {
width: 30%;
float: right;
}
.social-icon {
float: right;
padding-left: 10px;
padding-top: 15px;
width: 35px;
}
#facebook {
padding-right: 15px;
}
.coppyright {
color: #fff;
padding-left: 25px;
width: 40%;
float: left;
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
}
.name {
width: 60%;
height: 100%;
padding-left: 100px;
}
.helper {
display: inline-block;
height: 100%;
vertical-align: middle;
}
.logo {
width: 60%;
height: 100%;
float: right;
white-space:nowrap;
margin-top: 20px;
margin-right: 20%;
margin-left: 20%;
}
.logo-img {
width: 100%;
vertical-align: middle;
}
#nav {
width: 100%;
float: left;
margin: 0;
padding: 0;
list-style: none;
height: 50px;
}
#nav li {
float: left;
font-family: Ubuntu, sans-serif;
font-size: 20px;
}
#nav li a {
display: block;
padding-left: 15px ;
padding-right: 15px;
padding-top: 11px;
text-decoration: none;
font-weight: bold;
color: #fff;
height: 50px;
width: auto;
}
#nav li a:hover {
color: #fff;
background-color: #333333;
height: 39px;
}
#home {
margin-left: 20px;
}
html:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css"
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu:regular,bold&subset=Latin">
<title>Hackapi Mockup</title>
</head>
<!--This is where the navbar and splash title goes-->
<body><header>
<div class="navwrap">
<div class="nav">
<ul id="nav">
<li id="home">Home</li>
<li>News</li>
<li>Contact</li>
<li>About</li>
</ul>
</div>
</div>
<div class="name-logo">
<div class="logo">
<span class="helper"></span>
<img class="logo-img" src="https://imagizer.imageshack.us/v2/821x224q90/674/hloZoz.png">
</div>
</div>
</header>
<!--Main content and sidebar-->
<div class="content">
<h1>Lorem Ipsum</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div class="sidebar">
</div>
<!--Here is where all extra links, coppyrights and social media links go-->
<footer>
<div class="coppyright">
<h4>Coppyright Hackapi 2014</h4>
</div>
<div calss="social">
<img id="facebook" class="social-icon" src="https://imagizer.imageshack.us/v2/128x128q90/538/Kk3S3f.png">
<img id="twitter" class="social-icon" src="https://imagizer.imageshack.us/v2/128x128q90/913/xP6ctI.png">
<img id="gplus" class="social-icon" src="https://imagizer.imageshack.us/v2/128x128q90/536/nkHuql.png">
<img id="ytube" class="social-icon" src="https://imagizer.imageshack.us/v2/128x128q90/906/Sct7fy.png">
</div>
</footer>
</body>
I believe it is due to this style:
body {
overflow: hidden;
margin: 0;
}
You have to remove overflow:hidden as it is preventing the scrollbars from showing.
CSS:
overflow: auto;
OR
overflow-y: auto;
on body {}