Looking for assistance in creating contemporary gallery labels?

I am in the process of creating a portfolio website and I want to showcase some of my work from middle school. However, I would like to add a label to differentiate it from my current work.

The gallery features various images with different dimensions displayed on a small scale and slightly rotated. When you hover over an image, it enlarges to its original size.

The top half of this image shows the current state, while the bottom half depicts how I envision it to be.

I attempted to place a span with the label and the image inside it, but unfortunately, it did not work as expected.

Below is my code without the label:

<html>
<head>

    <title>
        Gallery Test
    </title>

    <style>

        .gallery_img {
            -moz-transform: scale(0.3);
            -moz-transition: all 0.4s ease-in-out 0s;
            background-color: white;
            padding: 20px;
            -webkit-box-shadow:  1px 1px 10px 2px rgba(0, 0, 0, 0.5);
            box-shadow:  1px 1px 10px 2px rgba(0, 0, 0, 0.5);
            margin: -100px -195px;
            z-index: 1;
        }

        .gallery_img:hover {
            -moz-transform: scale(1) rotate(0deg) !important;
            z-index: 100;
        }

    </style>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

<head>

<body>

    <img class="gallery_img" src="../images/no_image.png" />
    <img class="gallery_img" src="../images/no_image.png" />
    <img class="gallery_img" src="../images/no_image.png" />
    <img class="gallery_img" src="../images/no_image.png" />
    <img class="gallery_img" src="../images/no_image.png" />

    <br />

    <img class="gallery_img" src="../images/no_image.png" />
    <img class="gallery_img" src="../images/no_image.png" />
    <img class="gallery_img" src="../images/no_image.png" />
    <img class="gallery_img" src="../images/no_image.png" />
    <img class="gallery_img" src="../images/no_image.png" />

    <script>

        $(document).ready(function() {
            $(".gallery_img").each(function() {
                var numLow = -7;
                var numHigh = 7;

                var adjustedHigh = (parseFloat(numHigh) - parseFloat(numLow)) + 1;

                var numRand = Math.floor(Math.random()*adjustedHigh) + parseFloat(numLow);

                $(this).css("-moz-transform","scale(0.3) rotate(" + numRand + "deg)");
            });
        });

    </script>

</body>

Answer №1

I have a solution that involves setting the main image as a CSS background and placing the 'TEEN' overlay as the actual image itself.

It is important to ensure that the overlay image ('TEEN') is the same size as the main image for this method to work effectively.

Below is the code implementation of this technique. I have made changes to the first one and assigned it a class of .alt for demonstration purposes:

http://jsfiddle.net/SbrBz/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The success of a jquery ajax call always seems to elude me as it consistently throws

I've been facing an issue with my code snippet. The problem lies in the fact that the function on success is never executed; instead, it always triggers the error section. $.ajax({ url: 'http://localhost/zd/get_list', data: 'ter ...

Can I use Javascript to make changes to data stored in my SQL database?

I am delving into the realm of SQL and Javascript, aiming to insert my variable ("Val_Points from javascript") into a table ("Usuarios") associated with a specific user (e.g., Robert). Is it possible to achieve this using JavaScript, or are there alternati ...

Use Javascript to set cookies and remember the show state when clicked

Can you offer some advice? I am looking to add cookies to my simple JavaScript code. Currently, the div is displayed when clicking on a link, but it hides again when the page reloads. I would like to implement cookies to remember the show state for 7 days. ...

Sending a complicated data structure from the window.open function to an MVC Controller

I am currently working on a project involving JavaScript functionality that requires passing complex data from window.open() to an MVC Controller action method parameter. I was successful in achieving this by constructing a query string and retrieving the ...

Is it possible to use Ajax post with localhost on Wamp server?

Looking to execute a basic POST function using Ajax on my localhost WAMP server. Here's the code I have: function fill_table() { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari ...

Tips for aligning an icon in the middle of the Bootstrap 3 grid vertically

Struggling with vertical centering an icon at the end of a list item. The goal is to vertically center the right arrow on the page. Using Bootstrap 3, Angular-UI bootstrap JS, and AngularJS. Current code snippet: <style> .center { display: in ...

Fixed Sidebar Position Changes when Bootstrap Modal Closes

We are facing a peculiar issue in our React application involving a sidebar and a bootstrap modal. The problem arises when we click the "X" button in the modal, causing the sidebar to momentarily drop down the page before the modal closes. This strange be ...

Tips for wrapping a div element around another div at the top left corner

I am working with a particular layout. <div class="comment"> <div class="leftpart"> </div> <div class="rightpart"> </div> </div> When viewing on a desktop, I maintain the original styling where each div is in its own s ...

What is the best way to choose items with identical IDs and only change the ID to a new random one?

In the scenario where I have multiple input elements with the same id: <input type="text" id="first" attribute1="test" attribute2="hello" attribute3="happy"> <input type="text" id="first" attribute1="test" attribute2="hello" attribute3="happy"> ...

The element is not positioned correctly due to the absolute positioning

This is my first attempt at creating a jQuery plugin and I have almost got it working correctly. You can view the example here. I've been struggling for days to position an element as desired. The goal is to display some text with an optional downwar ...

JavaScript providing inaccurate height measurement for an element

Upon loading the page, I am trying to store the height of an element. To achieve this, I have utilized the jQuery "ready" function to establish a callback: var h_top; var h_what; var h_nav; $(".people").ready(function() { h_top = $(".to ...

Understanding fluid design concept

Check out this example. I've noticed that when resizing the viewport, the font size within the .main class increases while there is no change in the .aside class. Can someone help shed light on this for me? Thank you in advance! ...

Can someone guide me on how to align text to the bottom border of a page?

Is there a way to adjust the position of the header text ("bottom text") so that it appears just above the bottom border of the page? I have attempted modifying styles and classes within the footer, style, and h3 tags but have not had any success. Below ...

a guide on retrieving FormData objects in PHP

Hey everyone, I have a question regarding a sample code snippet I posted here. In this code, I am successfully uploading a file using Ajax JQuery. However, I am struggling to figure out how to read the content of the uploaded file in my PHP code. Can anyon ...

Maintaining the sequence of a PHP associative array when transferring it to JavaScript via ajax

Below is the code from my PHP file: GetUserArray.php $Users = array('7'=>'samei', '4'=>"chaya", '10'=>'abetterchutia'); echo json_encode($Users); Here is the AJAX request I am using: $.ajax({ ...

Error: The variable 'xxxxxx' is not recognized

Encountering an issue while trying to pass data via an onclick event and receiving the error message "Uncaught ReferenceError: 'xxxxxx' is not defined" var ShowDetails = function (insuredID) { $.ajax({ type: "GET", ...

CSS prefers to remain within its original controller and does not want to be uploaded from any other source

My webpage includes headers and footers with CSS in them. Strangely, when I load the view using one controller, the CSS displays correctly. But when I try to load the same view using a different controller, the CSS doesn't appear at all. What could b ...

The Bootstrap 4 card component is a versatile and stylish

Currently working on a display layout using Bootstrap 4, specifically utilizing cards. The issue I'm facing is that the text exceeds the limit of the card, causing it to overflow. Is there a solution to make the text automatically wrap to the bottom ...

What is the method to adjust the margin-left in an input checkbox?

Imagine you have: <div class="home"> <input type="checkbox"/>.... </div> I am trying to add margin-left:3px to the checkbox. This is my CSS code: .home+input[type=checkbox]{ margin-left:3px; } Can anyone assist me with this? ...

Struggling to find a solution for directing to the featured homes page without the content overlapping with my navbar and search component. Any assistance would be greatly

Looking for assistance with routing to the featured homes page without the content overlapping my navbar and search component. I simply want it to direct to a new URL without importing the components unless specifically needed. Check out this link I suspe ...