2

I am working on my project and I am trying to make this

enter image description here.

I want to make everything work on click for every image (so every image would have they own paper), need this to hover and I would like to use the toggle blind effect.

I was reading that it would be wise to use CSS Backgrounds on this, so I can swap pictures but I can not understand it.

I have taken some code to make a div who will hover on click, but I did not made desired effect.

jQuery(document).ready(function($) {
    $('.brownbox_trigger').click(function(event) {
        //prevent deafault action (hyperlink)
        e.preventDefault();

        //Get clicked link href
        var image_href = $(this).attr("href");

            /*
            If the brownbox window HTML already exists in document,
            change the img src to mach the href of whatever link wac c

            If the brownbox window HTML doesn't exists, create it and insert
            (This will only happen the first time around)
            */
        if ($('#brownbox').length > 0) { // #brownbox exists
            //place href as img src value
            $('#content').html('<img src="' + image_href + '" />');

            //show brownbox window
            $('#brownbox').show();
        }

        else {

            //create HTML markup for brownbox window
            var brownbox = 
            '<div id="brownbox">' +
            '<p>Click to close</p>' +
            '<div id="content">' + 
            '<img src="' + image_href + '" />' +
            '</div>' +
            '</div>';

            //insert brownbox into page
            $('body').append(brownbox);
        }
            /* Act on the event */
    });

    //Click enywhere on the page to get rid of the brownbox window
    $('#brownbox').live('click', function() {
        $('#brownbox').hide();
    });
    // Our script here

});

EDIT: I want to use SlideDown()-SlideUp() from jQuery(), so I have used some examples to make changes to mine HTML, but nothing is happening when I click over an image.

JSFiddle example.

I want to be able to click on it, and the hidden image div will appear containing text, then the jQuery will do the slide. Problem is that after I click on mine image nothing is happening, or as I see it, the whole picture is sliding down?

Can you help me over come this, thank you.

copser
  • 2,523
  • 5
  • 38
  • 73
  • "who will hover on click" .. what does it mean ?? – Richa Apr 08 '15 at 05:36
  • post a fiddle sample, so that you can clearly show your need.. – Aru Apr 08 '15 at 05:41
  • @Era, i mean, when you drag your cursor over it the picture will hover, after you click on it it will toggle, I did not post it right, sory – copser Apr 08 '15 at 05:49
  • @Aru, this is mine [fiddle](https://jsfiddle.net/1et5s06h/) for the cirxle div, I now need to wrap this animation in it – copser Apr 08 '15 at 05:54
  • 1
    Hello Petar, @Aru's [fiddle](http://jsfiddle.net/3tjv4e67/2/) (in the comments of his answer) is very good indeed,you need to integrate the idea into your responsive layout to the first part that will be visible for the screens except for extra small screens (lg, md,sm) and then for xs screens you might make your content divs to cover the whole screen with a close button somewhere to make it disappear just like a modal. – wooer Apr 09 '15 at 12:21
  • 1
    @wooer, thanks a lot for your comment. http://jsfiddle.net/3tjv4e67/2/ – Aru Apr 09 '15 at 12:29
  • I was also thinking to rewrite this screen div and do something like you did for the smaller screen, just to position tje to form a circle, and I can work whit this, tank you gys you are awesome @wooer – copser Apr 09 '15 at 13:32
  • You're welcome @Aru and Petar. Petar If Aru's answer is the answer of your question then I suggest you to mark it as an accepted answer and I suggest Aru to update his answer with the second version of his fiddle. – wooer Apr 09 '15 at 13:45
  • That's very kind of you @Aru, thank you. – wooer Apr 10 '15 at 06:31
  • I have done all, and it is superb, but just one small problem, @Aru left a note that this only work in firefox, I would like to change that to to work in all browsers, I have tested it in crome and only the Contetn1 is working, is it because of this 'content: attr(class)'°';', I guess I need to put this in the jQuery so it will work cross browser? – copser Apr 10 '15 at 08:24
  • 1
    @Idiomatic, I've tested the same in firefox, chrome and even in IE9 (but need to add vendor prefix for css transform, I've updated the css here for IE - http://jsfiddle.net/3tjv4e67/3/) it is working fine for me.. – Aru Apr 15 '15 at 04:28
  • @Aru thank you, the problem was in mine browser, I am using Chromium on Ubuntu, so he is not properly displaying this animation, but nevertheless I will update mine code now, tnx – copser Apr 15 '15 at 04:42
  • no issues, thanks for the response – Aru Apr 15 '15 at 05:39

2 Answers2

2

Hope you are looking for something like this

HTML

    <!-- content to be placed inside <body>…</body> -->
<div class='circle-container'>
    <!--<a href='#' class='circle center'><img src='http://imgsrc.hubblesite.org/hu/db/images/hs-2003-28-a-thumb.jpg'></a>
        <div class="content hidden">Content1</div>-->   <a href='#' class='circle deg0'><img src='http://imgsrc.hubblesite.org/hu/db/images/hs-1994-02-c-thumb.jpg'></a>
    <div class="content">Content1</div> <a href='#' class='circle deg45'><img src='http://imgsrc.hubblesite.org/hu/db/images/hs-2005-37-a-thumb.jpg'></a>
    <div class="content hidden">Content2</div>  <a href='#' class='circle deg135'><img src='http://imgsrc.hubblesite.org/hu/db/images/hs-2010-26-a-thumb.jpg'></a>
    <div class="content hidden">Content3</div>  <a href='#' class='circle deg180'><img src='http://imgsrc.hubblesite.org/hu/db/images/hs-2004-27-a-thumb.jpg'></a>
    <div class="content hidden">Content4</div>  <a href='#' class='circle deg225'><img src='http://imgsrc.hubblesite.org/hu/db/images/hs-1992-17-a-thumb.jpg'></a>
    <div class="content hidden">Content5</div>  <a href='#' class='circle deg315'><img src='http://imgsrc.hubblesite.org/hu/db/images/hs-2004-32-d-thumb.jpg'></a>
    <div class="content hidden">Content6</div>
</div>

CSS

    /**
 * Position icons into circle (SO)
 * http://stackoverflow.com/q/12813573/1397351 
 */
 .hidden {
    display:none;
}
.active {
    filter: brightness(200%);
    border-radius:50px;
    transition: all 1s;
}
.content {
    position:absolute;
    padding:10px;
    border:1px solid #dedede;
    border-radius:5px;
    background: #eeeeee;
    top:46%;
    left:41%;
}
.circle-container {
    position: relative;
    width: 24em;
    height: 24em;
    padding: 2.8em;
    /*= 2em * 1.4 (2em = half the width of an img, 1.4 = sqrt(2))*/
    /*border: dashed 1px;*/
    border-radius: 50%;
    margin: 1.75em auto 0;
}
.circle-container a {
    display: block;
    overflow: hidden;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4em;
    height: 4em;
    margin: -2em;
    /* 2em = 4em/2 */
    /* half the width */
}
.circle-container img {
    display: block;
    width: 100%;
}
.deg0 {
    transform: translate(12em);
}
/* 12em = half the width of the wrapper */
 .deg45 {
    transform: rotate(45deg) translate(12em) rotate(-45deg);
}
.deg135 {
    transform: rotate(135deg) translate(12em) rotate(-135deg);
}
.deg180 {
    transform: translate(-12em);
}
.deg225 {
    transform: rotate(225deg) translate(12em) rotate(-225deg);
}
.deg315 {
    transform: rotate(315deg) translate(12em) rotate(-315deg);
}
/* this is just for showing the angle on hover */
 .circle-container a:not(.center):before {
    position: absolute;
    width: 4em;
    color: white;
    opacity: 0;
    background: rgba(0, 0, 0, .5);
    font: 1.25em/3.45 Courier, monospace;
    letter-spacing: 2px;
    text-decoration: none;
    text-indent: -2em;
    text-shadow: 0 0 .1em deeppink;
    transition: .7s;
    /* only works in Firefox */
    /* content: attr(class)'°';*/
}
.circle-container a:hover:before {
    opacity: 1;
}
/* this is for showing the circle on which the images are placed */
 .circle-container:after {
    position: absolute;
    top: 2.8em;
    left: 2.8em;
    width: 24em;
    height: 24em;
    /*border: dashed 1px deeppink;*/
    border-radius: 50%;
    opacity: .3;
    pointer-events: none;
    content:'';
}
.circle-container:hover:after {
    opacity: 1;
}
.circle-container a:not(.center):after {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    box-shadow: 0 0 .5em .5em white;
    margin: -2px;
    background: deeppink;
    opacity: .3;
    content:'';
}
.circle-container:hover a:after {
    opacity: 1;
}
.circle-container a:hover:after {
    opacity: .3;
}

Script

$(".circle").click(function () {
    $(".content").hide(800);
    $(".circle").removeClass("active");
    $(this).addClass("active");
    $(this).next(".content").slideDown(1000);
});

Fiddle Demo

Aru
  • 1,840
  • 1
  • 12
  • 15
  • sorry i cant get you clearly, have a look into this sample.. http://jsfiddle.net/3tjv4e67/ – Aru Apr 09 '15 at 10:46
1

This is what you need exactly : Fiddle example

Complete work is of CSS only:

ul li a {
    width:134px;
    height:53px;
    display:block;
}
.iconOne {
    background:url("http://www.studiopress.com/images/blog/click-here-buttons.jpg") no-repeat scroll -82px -58px;
}
.iconTwo {
    background:url("http://www.studiopress.com/images/blog/click-here-buttons.jpg") no-repeat scroll -244px -58px;
}
.iconThree {
    background:url("http://www.studiopress.com/images/blog/click-here-buttons.jpg") no-repeat scroll -403px -58px;
}
a.iconOne:hover {
    background-position:-82px -123px;
}
li.active a.iconOne:hover, li.active a.iconOne {
    background-position:-82px -188px;
}
a.iconTwo:hover {
    background-position: -244px -123px;
}
li.active a.iconTwo:hover, li.active a.iconTwo {
    background-position: -244px -188px;
}
a.iconThree:hover {
    background-position:-403px -123px;
}
li.active a.iconThree:hover, li.active a.iconThree {
    background-position:-403px -188px;
} 

And use above mentioned classes:

<ul>
    <li>
        <a href="#" class="iconOne"></a>
    </li>
     <li>
        <a href="#" class="iconTwo"></a>
    </li>
     <li>
        <a href="#" class="iconThree"></a>
    </li>
</ul>
Richa
  • 4,240
  • 5
  • 33
  • 50