Here is the link to my site that I'm building:
http://joshrcook.com/test
I'm having trouble getting the pictures to touch top and bottom without messing up firefox's columns. I can float the images left, but that seems to break -moz-column-count. Any ideas?
Here is the html for the pictures:
<div id="img-wrapper">
<?php for($i = 1; $i <=25; $i++) { ?>
<div class="photo">
<img src="img/arrow_up_alt1_32x32.png" class="overlay overlay1" />
<img src="img/fullscreen_32x32.png" class="overlay overlay2" />
<img src="img/heart_fill_32x38.png" class="overlay overlay3" />
<?php echo '<img src="img/tumblr_img_' . $i . '.jpg" class="main_photo" />'; ?>
</div>
<?php } ?>
</div>
And here is the CSS:
#img-wrapper {
width: 960px;
-moz-column-count: 3;
-webkit-column-count: 3;
column-count: 3;
}
.photo {
width: auto;
position: relative;
width: 320px;
}
.photo a img.overlay {
position: absolute;
z-index: 10;
top: 0;
left: 0;
}
.photo a img.overlay1 {
left: 25%;
}
.photo a img.overlay2 {
left: 45%;
}
.photo a img.overlay3 {
left: 65%;
}
.photo img.main_photo {
width: 320px;
border-radius: 10px;
}
.photo {
width: auto;
position: relative;
width: 320px;
margin-bottom: -5pt;
}
The above seems to work great in Chrome (release) and IE9. I don't have other browsers to test with on this machine, but I'd start there.
Also possibly it could be because of how the browsers are interpreting your whitespace (margins/padding all look like they're set at 0, so the problem shouldn't be there. Try eliminating whitespace within every <div class="photo"></div> and see what that does.
Related
I made an example on CodePen - CodePen
I want the image to disappear on hover with the mouse and a block with text appears.
My problem is that I don't understand how to remove the jumps if I want to keep the text.
Now there are unpleasant jumps in my layout, which is caused by display: none;.
And I think to add smooth transitions. For reuse, I moved the code to Alpine.data. Is this a good idea?
I've used alpine before with tilewind and it's easier. But in this bootstrap project, there are complications.
Please tell me what are your ideas?
Thanks in advance!
<div class="container advantage-pic">
<div class="pic1" x-data="onHover" #mouseover="visible" #mouseleave="novisible">
<img class="pic" x-show="!open" src="https://napli.ru/advantage-pic1.png" alt="">
<div class="txt" x-cloak x-show="open" >Some text</div>
</div>
<div class="pic2" x-data="onHover" #mouseover="visible" #mouseleave="novisible">
<img class="pic" x-show="!open" src="https://napli.ru/advantage-pic2.png" alt="">
<div class="txt" x-cloak x-show="open">Some text</div>
</div>
<div class="pic3" x-data="onHover" #mouseover="visible" #mouseleave="novisible">
<img class="pic" x-show="!open" src="https://napli.ru/advantage-pic3.png" alt="">
<div class="txt" x-cloak x-show="open">Some text</div>
</div>
<div class="pic4" x-data="onHover" #mouseover="visible" #mouseleave="novisible">
<img class="pic" x-show="!open" src="https://napli.ru/advantage-pic4.png" alt="">
<div class="txt" x-cloak x-show="open">Some text</div>
</div>
</div>
[x-cloak] {
display: none !important;
}
.advantage-pic {
max-width: 760px;
margin: auto;
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-template-rows: repeat(4, 1fr);
grid-column-gap: 12px;
grid-row-gap: 12px;
}
.pic1 {
grid-area: 1 / 1 / 3 / 2;
text-align: center;
position: relative;
}
.pic2 {
grid-area: 1 / 2 / 2 / 3;
text-align: center;
position: relative;
}
.pic3 {
grid-area: 2 / 2 / 3 / 3;
text-align: center;
position: relative;
}
.pic4 {
grid-area: 3 / 1 / 4 / 3;
text-align: center;
position: relative;
}
.txt {
color: blue;
background: #fe980f;
position: absolute;
top: 0;
left: 0;
transition: height 500ms ease 0s;
width: 100%;
display: block;
height: 100%;
}
.pic {
width: 100%;
height: 100%;
object-fit: cover;
}
import Alpine from "https://cdn.skypack.dev/alpinejs#3.10.5";
Alpine.data("onHover", () => ({
open: false,
visible() {
this.open = true;
},
novisible() {
this.open = false;
},
}));
queueMicrotask(() => {
Alpine.start();
});
Solved! There was no need to hide the picture, there was no jump!
x-show="!open"
Ive tried all sorts of tutorials and then all seems to include this code.
<span class = ""> <i class=""><i/> <i class=""><i/> </span>
This dosen't seem to work,
Ive also tried this
</i>
It dosent seem to work. Please help, Thank you so much!.
IM using this rn
<nav class="navbar">
<div class="logo-box"><img src="../logos/foschini.png" class="logo"></div>
<ul>
<li>Hire an Engineer</li>
<li>Hiring</li>
<li>Plans</li>
<li>About us</li>
</ul>
<span class="hamburger">
<i class="bar">Hire</i>
<i class="bar">Hiring</i>
<i class="bar">Plans</i>
<i class="bar">About us</i>
</span>
</nav>
This is what I used:
scss:
$primary-color: #ffd000;
#SideMenuTrigger {
position: fixed;
right: 10em;
top: 50%;
transform: translateY(-50%);
transition: right 200ms;
width: 3.5em;
height: 3em;
border: none;
background: none;
padding: 0;
span {
position: absolute;
height: 18%;
background-color: $primary-color;
width: 100%;
transition: width 200ms, transform 200ms, opacity 200ms;
transition-timing-function: ease-in;
pointer-events: none;
right: 0;
opacity: 1;
&:nth-child(1) {
top: 0;
transform-origin: bottom right;
width: 90%;
}
&:nth-child(2) {
top: 50%;
transform: translateY(-50%);
width: 70%;
}
&:nth-child(3) {
bottom: 0;
transform-origin: top right;
width: 60%;
}
}
&:hover {
span {
&:nth-child(1) {
width: 100%;
}
&:nth-child(2) {
width: 50%;
}
&:nth-child(3) {
width: 65%;
}
}
}
&.is-open {
right: 2em;
span {
&:nth-child(1) {
width: 100%;
transform: rotateZ(-42deg);
}
&:nth-child(2) {
width: 100%;
transform: translate(20px, -50%);
opacity: 0;
}
&:nth-child(3) {
width: 100%;
transform: translateY(21%) rotateZ(42deg);
}
}
}
}
}%
html:
<button id="SideMenuTrigger">
<span></span>
<span></span>
<span></span>
</button>
if the menu is active add "is-open" class to button
I'm currently refactoring my website and try to get rid of a few breakpoints.
In my portfolio, I have an image gallery, which displays 3x3 image tiles. Those tiles are built with css grid. The tiles in my example should be 200px high and minmax (200px, 333px) width.
Currently, the tiles work as expected. But the images don't keep their aspect ratio. Is there any way to keep the original ratio and cut the images in their height? The smallest version of the container should be 200x200.
https://codepen.io/yanniksturm/pen/LYVegro
<div class="content">
<div id="img1" class="imageWrapper">
<img src="https://images.unsplash.com/photo-1562886889-4ff7af0602ef?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2089&q=80">
</div>
<div id="img2" class="imageWrapper">
<img src="https://images.unsplash.com/photo-1562886889-4ff7af0602ef?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2089&q=80">
</div>
<div id="img3" class="imageWrapper">
<img src="https://images.unsplash.com/photo-1562886889-4ff7af0602ef?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2089&q=80">
</div>
</div>
.content {
min-width: 600px;
max-width: 999px;
margin: auto;
width: 80%;
backgeound-color: red;
display: grid;
grid-template-columns: minmax (200px, 333px) minmax (200px, 333px) minmax (200px, 333px);
grid-template-rows: 200px;
}
.imageWrapper {
height: 100%;
width: 100%;
}
img {
height: 100%;
width: 100%;
}
#img1 {
grid-column: 1;
}
#img2 {
grid-column: 2;
}
#img3 {
grid-column: 3;
}
Thanks a lot for your help!
You need to set your img width and height to auto and add a max-width: 100%; to it in order to keep the aspect ratio.
img {
height: auto;
width: auto;
max-width: 100%;
}
See below snippet.
You could use object-fit: cover; but that is not supported in older browsers (I am looking at IE11).
.content {
min-width: 600px;
max-width: 999px;
margin: auto;
width: 80%;
backgeound-color: red;
display: grid;
grid-template-columns: minmax (200px, 333px) minmax (200px, 333px) minmax (200px, 333px);
grid-template-rows: 200px;
}
.imageWrapper {
height: 100%;
width: 100%;
border: 1px solid red;
}
img {
height: auto;
width: auto;
max-width: 100%;
}
#img1 {
grid-column: 1;
}
#img2 {
grid-column: 2;
}
#img3 {
grid-column: 3;
}
<div class="content">
<div id="img1" class="imageWrapper">
<img src="https://images.unsplash.com/photo-1562886889-4ff7af0602ef?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2089&q=80">
</div>
<div id="img2" class="imageWrapper">
<img src="https://images.unsplash.com/photo-1562886889-4ff7af0602ef?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2089&q=80">
</div>
<div id="img3" class="imageWrapper">
<img src="https://images.unsplash.com/photo-1562886889-4ff7af0602ef?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2089&q=80">
</div>
</div>
I'd like to know how can I code the 3 blocks fader from the Spring.io website. Image here:
It has a dividing line that changes the image gradually as you move it.
This can be done with simple HTML and javascript code. Here's the complete jsfiddle https://jsfiddle.net/zn3b1hov/34/
Basic Idea is very simple.
First, You need 2 SVG images one is colored and another is grayscale. I am using this 2
grayscale-image
colored-image
Now Create 2 absolute div one on top of another and use these images as background.
Then create a slider as wide as the images. I am using HTML range type input
Finally change the top div's width according to sliders value.
Complete HTML, CSS and JS
<style>
#fader-diagram-your-app {
position: relative;
height: 286px;
}
#fader-diagram-modern-java-gray {
position: absolute;
height: 238px;
width: 800px;
margin: 31px auto;
background: url('https://spring.io/img/homepage/diagram-modern-java-gray-9a417697a51646e42df7e9d7f024709d.svg') no-repeat;
background-size: 100%;
}
#fader-diagram-modern-java-color {
position: absolute;
height: 238px;
max-width: 800px;
margin: 31px auto;
overflow: hidden;
width: 200px;
}
#fader-diagram-modern-java-color div {
position: absolute;
height: 238px;
background: url('https://spring.io/img/homepage/diagram-modern-java-color-e10b7eec68b1fe60eefeab0cf20a20da.svg') no-repeat;
background-size: 100%;
width: 800px;
}
#fader {
background-color: #34302d;
width: 6px;
height: 275px;
border-radius: 4px;
position: absolute;
left: 0;
}
#myRange {
width: 800px;
position: absolute;
top: 50%;
}
</style>
<div id="fader-diagram-your-app">
<div class="sidebyside" id="fader-diagram">
<div id="fader-diagram-modern-java-gray"></div>
<div id="fader-diagram-modern-java-color" style="width: 39.6875px;">
<div></div>
</div>
<div id="fader">
</div>
<input type="range" min="0" max="800" value="0" class="slider" id="myRange">
</div>
</div>
<script>
var slider = document.getElementById("myRange");
var coloredImage = document.getElementById("fader-diagram-modern-java-color");
var fader = document.getElementById("fader");
slider.oninput = function() {
coloredImage.style.width = this.value + "px";
fader.style.left = this.value + "px";
}
</script>
I am trying to use the background-size property in IE8 with this promising solution: https://github.com/louisremi/background-size-polyfill
But I am getting this error: SCRIPT65535: Unexpected call to method or property access.
Any ideas or alternatives to set the image size of a background-image in IE8?
It might be worth noting that the polyfill isn't designed to work with specific pixel sizes, i.e. background-size: 32px 64px
I know this doesn't answer your question, but for IE 8, I've just been removing non-important backgrounds with this CSS hack (instead of trying to figure out how to size them)
background: none\9;
try this css code, ie8 working dropshadow
body {
margin: 0;
background: url(images/algeria.jpg) center no-repeat;
-ms-behavior: url(backgroundsize.min.htc);
}
.bgsCover {
background-size: cover;
}
.bgsContain {
background-size: contain;
}
/* this allows to use a second background in all browsers and IE8 */
body:after {
content: "";
background: url(images/pattern.png) repeat;
position: absolute;
z-index: -1;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
/* responsive carousel FTW */
#carousel {
height: 45%;
width: 50%;
margin: 0 auto;
background: #0F0808;
border-radius: 3px;
}
#carousel ul {
height: 100%;
padding: 0;
margin: 0;
list-style: none;
}
#carousel li {
display: none;
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: contain;
-ms-behavior: url(backgroundsize.min.htc);
}
#carousel .active {
display: block;
}
/* less interesting stuff below */
html, body {
height: 100%;
font-family: "Arial", "Liberation Sans", sans-serif;
color: #FEE;
}
h1 {
font-family: 'Great Vibes', sans-serif;
text-align: center;
margin: 0 0 40px;
text-shadow: 0 0 2px #222;
font-size: 1.7em;
font-weight: normal;
position: relative;
top: 20px;
filter: progid:DXImageTransform.Microsoft.Shadow(color=#222222, direction=90);
}
h1 i {
font-size: 1.3em;
display: block;
-moz-transform: rotate(-15deg);
-webkit-transform: rotate(-15deg);
-o-transform: rotate(-15deg);
-ms-transform: rotate(-15deg);
transform: rotate(-15deg);
filter: progid:DXImageTransform.Microsoft.Shadow(color=#222222, direction=90);
}
p {
text-align: center;
font-size: 1.5em;
text-shadow: 0 0 2px #222;
/* For IE 8 */
filter: progid:DXImageTransform.Microsoft.Shadow(color=#222222, direction=90);
/* For IE 5.5 - 7 */
zoom: 1;
color: #CCC
}
.button {
color: #0F0808;
text-decoration: none;
background: #FEE;
border-radius: 3px;
text-shadow: none;
padding: 4px 8px;
}
Your HTML Source code
<body class="bgsCover">
<h1><i>background-size</i> polyfill</h1>
<img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png" alt="Fork me on GitHub">
<div id="carousel">
<ul>
<li id="img1" class="active" style="background-image: url(images/algerian1.jpg);">
<li id="img2" style="background-image: url(images/jar1.jpg);">
<li id="img3" style="background-image: url(images/algerian2.jpg);">
<li id="img4" style="background-image: url(images/jar2.jpg);">
</ul>
</div>
<p>Stretch background image using CSS3 <code>background-size: cover;</code> and <code>background-size: contain;</code>, in IE8 too.<br/>
Reacts to resize events for responsive backgrounds and galeries!</p>
<p><a class="button" href="https://github.com/louisremi/background-size-polyfill#readme">Instructions</a> - <a class="button" href="https://github.com/louisremi/background-size-polyfill/downloads">Downloads</a></p>
<script>
/*var images = [
'algeria.jpg',
'parthenon.jpg',
'propylaea.jpg'
],
curImg = 0;
document.getElementById("switchImage").onclick = function() {
curImg = ( curImg + 1 ) % images.length;
document.body.style.backgroundImage = "url(images/" + images[ curImg ] + ")";
};
var sizes = [
"Cover",
"Contain",
"Auto"
],
curSize = 0;
document.getElementById("switchSize").onclick = function() {
curSize = ( curSize + 1 ) % sizes.length;
document.body.className = "bgs" + sizes[ curSize ];
};*/
var items = document.querySelectorAll("#carousel li"),
curItem = 0;
setInterval(function() {
items[ curItem ].className = "";
curItem = ( curItem + 1 ) % items.length;
items[ curItem ].className = "active";
}, 3000);
</script>
</body>
i got the same issue on IE8. When i copied ".htaccess" in root folder. It works perfectly.
The Polyfill did not work for me either. My solution was to use the original "deprecated" version.
<!--[if lt IE 9]>
<script
src="//louisremi.github.io/jquery.backgroundSize.js/jquery.backgroundSize.js">
</script>
<script>
$('.logo').css( "background-size", "cover" );
</script>
<![endif]-->
Actually the deprecated version is not necesary.
For me it worked when I used behavior instead of -ms-behavior