Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

98sfsdf8

Members
  • Joined

  • Last visited

  1. So I came across Jason Knight's random thumb position snippet over at https://forums.htmlhelp.com/ - a non-jquery effort! Now, I am trying to make multiples of these grey divs, that also appear in random positions when a page is refreshed. Ideally it would be scalable (i.e.. I will have max 10 grey divs). HTML <div class="buttonThumbs"> <button type="button">text</button> <img src="https://placeimg.com/100/100/animals" alt="describe this, alt is not optional"> <img src="https://placeimg.com/100/100/people" alt="describe this, alt is not optional"> <img src="https://placeimg.com/100/100/tech" alt="describe this, alt is not optional"> <img src="https://placeimg.com/100/100/nature" alt="describe this, alt is not optional"> <!-- .buttonThumbs --></div> CSS html, body { height:100%; } body { display:flex; align-items:center; justify-content:center; } .buttonThumbs { position:relative; width:30em; height:20em; max-width:100%; max-height:100%; margin:auto; /* force scrollbars if too small */ background:#EEE; } .buttonThumbs > * { position:absolute; } .buttonThumbs button { top:50%; left:50%; border:0; background:transparent; transform:translate(-50%, -50%); } .buttonThumbs img { width:100px; height:100px; opacity:0; transition:opacity 1s; } .buttonThumbs button:focus ~ img, .buttonThumbs button:hover ~ img { opacity:1; } .buttonThumbs img:nth-of-type(1) { top:25%; left:25%; } .buttonThumbs img:nth-of-type(2) { top:25%; left:75%; } .buttonThumbs img:nth-of-type(3) { top:75%; left:25%; } .buttonThumbs img:nth-of-type(4) { top:75%; left:75%; } JS { // scope isolating block const origins = [ { x : 0, y : 0 }, { x : 0, y : 1 }, { x : 1, y : 1 }, { x : 1, y : 0 }, ], buttonImgEvent = (e) => { let img = e.currentTarget.nextElementSibling; if (img) { let originIndex = Math.floor(origins.length * Math.random()); const wrapper = e.currentTarget.closest(".buttonThumbs"), halfWidth = wrapper.clientWidth / 2, halfHeight = wrapper.clientHeight / 2; do { img.style.left = ( Math.random() * (halfWidth - img.clientWidth) + origins[originIndex].x * halfWidth ) + "px"; img.style.top = ( Math.random() * (halfHeight - img.clientHeight) + origins[originIndex].y * halfHeight ) + "px"; originIndex = (originIndex + 1) % origins.length; } while (img = img.nextElementSibling); } }; for (const button of document.querySelectorAll(".buttonThumbs button")) { button.addEventListener("mouseover", buttonImgEvent); button.addEventListener("focus", buttonImgEvent); } } // end scope isolation Here is his codepen: https://codepen.io/jason-knight/pen/ZEjKvVd
  2. yes on phone it is a completely different setup. fiddle: really? for me it works fine (Latest version of brave)
  3. I would like that when a user hovers different words, that a random arrangement of thumbnails fades-in. Some caveats: thumbs should stay fairly close to the corresponding text. thumbs can overlap, but not fully. both the text and the thumb positions should be random on every page refresh text and thumbs shouldn't fall outside the screen. should be scalable (i.e.. I will have max. 10 texts and max. 10 thumbs for every text. the thumbs could spread concentrically if need be) And here's a fiddle of what I have so far: https://jsfiddle.net/2jddfsjad/ewk4dzLp/9/ See the image for an example of what I mean:
  4. hi all, I have always made my pages "by hand". just coding them, a bit of javascript here and there. And because I like to experiment with designs, i use a lot of popup divs, which means i use "display:none" tags for those divs. I've been told that this could be hurting my searchability. The pages have been online for a long time. does anyone have some advice on this? Someone has been mentioned that I will have difficulty with SEO and that I need to use a CMS like wordpress. what do you think my next move should be? Is there something in my CSS I can change, or do I go the CMS route? thanks!
  5. I have several modals, each with a different iframe with a different embedded youtube video. When someone closes out of the modal (either by clicking away, hitting ESC or closing it), I would like the youtube video in the modal to stop. I am not using bootstrap. Below is an example of just one of the modals in action. Any suggestions will help! Fiddle HTML <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <a href="#" class="button" data-modal="#modal2">Modal2</a> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate.</p> <div id="modal2" class="modal"> <div class="modal-content"> <a class="close">×</a> <h2>This is an image description 2</h2> <div class="video-container"><iframe class="youtube-video" width="560" height="315" src="https://www.youtube.com/embed/3VZFpwlXKpg?enablejsapi=1&mute=0&loop=1&version=3&playerapiid=ytplayer" frameborder="0" allowfullscreen></iframe> </div> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate.</p> </div> </div> CSS /* Modal */ .modal { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 9999999; display: none; background: rgba(255, 255, 255, 0.5); } /* Fullscreen BG */ .modal-content h2 {font-size: 1.0em; } .modal-content { width: 80%; height: 80vh; overflow-x: hidden; overflow-y: auto; margin: 10% auto; font-size: 1.2em; } .close {line-height: 25px; font-size: 1.0em; position: absolute; right: -24px; text-align: center; top: -6px width: 24px; z-index: 9999999; text-decoration: none; font-weight: bold; cursor: pointer; } .close:hover { color: grey; } /* Youtube */ .video-container { overflow: hidden; position: relative; width:100%; } .video-container::after {padding-top: 56.25%; display: block; content: ''; } .video-container iframe {position: absolute; top: 0; left: 0; width: 100%; height: 100%; } JS //Model $(".button").on("click", function() { var modal = $(this).data("modal"); $(modal).fadeIn(); }); //click away to close model $(".modal").on("click", function(e) { var className = e.target.className; if (className === "modal" || className === "close") { $(this).closest(".modal").fadeOut(); } }); //ESC close model $(document).keydown(function(e) { var code = e.keyCode || e.which; if (code == 27) $(".modal").fadeOut(); });
  6. Having a few issues with a CSS Button effects not working across browsers. It displays as I would like it in Chrome, but not Firefox. Can't seem to find the root of the problem. Here is what I have. Fiddle <a class="soft">Button</a> a.soft { display: inline-block; font-family: 'Varela Round', sans-serif; padding: 2rem 3rem; font-size: 1.25vw; box-shadow: -10px -10px 20px 0 #E6E6E6, 10px 10px 20px 0 #ABABAB, inset 10px 10px 20px 0 #E6E6E6, inset -10px -10px 20px 0 #ABABAB; border-radius: 50px; transform: box-shadow 1s ease-in-out; background-color: #666666; -webkit-background-clip: text; color: transparent; text-shadow: rgba(245, 245, 245, 1.0) 2px 2px 5px; font-weight: bolder; } a.soft:hover { background-color: #ddd; box-shadow: -10px -10px 20px 0 #E6E6E6, 10px 10px 20px 0 #ABABAB, inset 10px 10px 20px 0 #E6E6E6, inset -10px -10px 20px 0 #ABABAB; color: #888; } a.soft:active { box-shadow: 0 0 20px 0 #E6E6E6, 0 0 20px 0 #ABABAB, inset 0 0 20px 0 #E6E6E6, inset 0 0 20px 0 #ABABAB; color: #D8D8D8; text-shadow: 1px 1px 2px white; -webkit-background-clip: text; font-weight: bolder; }
  7. hi all, I have a bit of css code and each div child needs to have a property. Hence it looks like this. It goes from 0 all the way to 19. div:nth-child(0) { transform: translate3D(0%, 0%, calc(var(--itemZ) * var(--cameraSpeed) * 0 * -1px)); } div:nth-child(1) { transform: translate3D(0%, 0%, calc(var(--itemZ) * var(--cameraSpeed) * 1 * -1px)); } div:nth-child(2) { transform: translate3D(0%, 0%, calc(var(--itemZ) * var(--cameraSpeed) * 2 * -1px)); } [...] div:nth-child(17) { transform: translate3D(0%, 0%, calc(var(--itemZ) * var(--cameraSpeed) * 17 * -1px)); } div:nth-child(18) { transform: translate3D(0%, 0%, calc(var(--itemZ) * var(--cameraSpeed) * 18 * -1px)); } div:nth-child(19) { transform: translate3D(0%, 0%, calc(var(--itemZ) * var(--cameraSpeed) * 19 * -1px)); } Is there a way that I can make it so it understands 0-19 in one line only? Any ideas?
  8. Hi all, I am having a bit of a problem. I have a script that is for nested modals, that when a link is clicked it jumps straight to an anchor. It works fine. However when styling, I would like to have a fixed header as the ".content" div scrolls to the anchor. When ".content" has a height of 80vh it looks fine, but the script doesn't scroll to the anchor. When ".content" has a height of 80% the script works, but the fixed header doesn't stay fixed and scrolls with the ".content". How can I have the script work, but keep a fixed header. Thanks HERE IS A FIDDLE <a href="#contributors" class="element-item bailey">Bailey</a> <a href="#contributors" class="element-item huijnen">Huijnen</a> <div id="contributors" class="modal"> <div class="modal-container"> <header><span class="close">×</span> <h2>Contributors</h2> </header> <div class="content"> <section> <article> <br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line <div class="item" id="huijnen"> <h4>Huijnen</h4> </div> <br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line <div class="item" id="bailey"> <h4>Bailey</h4> </div> <br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line </article> </section> </div> </div> </div> JS //popup nest modals $(function() { const openModals = []; $('.element-item').click(e => { e.preventDefault(); $(e.currentTarget).closest('.modal').add('body').addClass('open'); openModals.push($($(e.currentTarget).attr('href')).show()); }); $(window).add('.close').click(e => { e.stopPropagation(); if ($(e.target).is('.modal, .close')) { const closing = openModals.pop().addClass('modal-content-active'); setTimeout(() => { closing.hide().removeClass('modal-content-active') }, 0); if (openModals.length > 0) { openModals[openModals.length - 1].removeClass('open'); } else $('body').removeClass('open'); } }); }); //jump to anchor in modal $('.huijnen').on('click', function(e) { requestAnimationFrame(() => $('#contributors').animate({ scrollTop: $('#huijnen').offset().top - 40 }, 500)) }); $('.bailey').on('click', function() { requestAnimationFrame(() => $('#contributors').animate({ scrollTop: $('#bailey').offset().top - 40 }, 500)) }); CSS .modal { box-sizing: border-box; display: none; position: fixed; z-index: 1; padding-top: 3.125rem; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; transition: all 1.0s ease; } /* The Close Button */ .close { z-index: 1000; font-size: 3vw; float: right; transition: all 0.3s ease; } /* Modal Content */ header, .content { width: 60%; margin: auto; } .content { height: 80%; padding-top: 3%; padding-bottom: 3%; -ms-flex: 1 1 auto; -webkit-flex: 1 1 auto; flex: 1 1 auto; overflow: auto; min-height: 0; font-size: 2vw; }
  9. over at stackexchange @marzelin suggested the following which works fine:
  10. Hi all, I am trying to create a link that when clicked, a modal pops up, and also jumps to an anchor in it. At the moment you will see i have some code for the pop up (which is configured for a set of nested modals) hence it is not your standard setup. When you click on the links twice, they work. How can I get it to work as is, with one click only. Thanks HTML <a href="#contributors" class="element-item item1">item1</a> <a href="#contributors" class="element-item item2">item2</a> <!-- The Modal --> <div id="contributors" class="modal"> <header><span class="close">×</span></header> line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line <div class="item" id="item1"><h4>Item 1</h4></div> <br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line <div class="item" id="item2"><h4>Item 2</h4></div> <br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line<br>line </div> JS //popup nested modals $(function () { const openModals = []; $('.element-item').click(e => { e.preventDefault(); $(e.currentTarget).closest('.modal').add('body').addClass('open'); openModals.push($($(e.currentTarget).attr('href')).show()); }); $(window).add('.close').click(e => { e.stopPropagation(); if ($(e.target).is('.modal, .close')) { const closing = openModals.pop().addClass('modal-content-active'); setTimeout(() => {closing.hide().removeClass('modal-content-active')}, 0); if (openModals.length > 0) { openModals[openModals.length - 1].removeClass('open'); } else $('body').removeClass('open'); } }); }); //jump to anchor in modal $('.item1').on('click',function(){ $('#contributors').animate( { scrollTop: $('#item1').offset().top -40 }, 500); }); $('.item2').on('click',function(){ $('#contributors').animate( { scrollTop: $('#item2').offset().top -40 }, 500); }); CSS .modal{ width: 300px; height: 200px; overflow: auto; display: none; } Here is a fiddle
  11. by changing `e.target` to `e.currentTarget` , it worked. JavaScript: $('.modal-button').click(e => { e.preventDefault(); $(e.currentTarget).closest('.modal').add('body').addClass('open'); openModals.push($($(e.currentTarget).attr('href')).show()); });
  12. I am having an issue where a modal isn't triggering if it is wrapped in an <em> tag. In my example, if you click in the "normal" font-style part of the link, it fires properly, if you click where the italics are, it won't. Any ideas? JS $(function () { const openModals = []; $('.modal-button').click(e => { e.preventDefault(); $(e.target).closest('.modal').add('body').addClass('open'); openModals.push($($(e.target).attr('href')).show()); }); $(window).add('.close').click(e => { e.stopPropagation(); if ($(e.target).is('.modal, .close')) { const closing = openModals.pop().addClass('modal-content-active'); setTimeout(() => {closing.hide().removeClass('modal-content-active')}, 0); if (openModals.length > 0) { openModals[openModals.length - 1].removeClass('open'); } else $('body').removeClass('open'); } }); }); FIDDLE
  13. again you nailed it! amazing...
  14. for example imagine if the "Bismuth" div is unaffected by both search and a filter, and just stays put. like a sticky header would
  15. fantastic! works like a charm! would you know how keep one ".element-item" always in the same place? ie. as though it is "sticky"?

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.