How we can create a horizontally aligned image showcase using HTML, CSS, and JS? Solution: See this Horizontal Portfolio Layout Using jQuery and CSS Animation.
Previously I have shared some portfolio related programs, but this is a portfolio layout that has horizontal placement and animations. Basically, a portfolio section for showing works, projects, and other kinds of images on a website. Mostly we show our works in the portfolio section, and it is a good way to present your work on the internet. This program is about how you can create your portfolio layout to present your work or anything else.
Today you will learn to create a jQuery and CSS based portfolio layout. Basically, there are some images with up-down placement in odd and even order. Below the images, there is a scrollbar to see all the images. All the images place horizontally left to right alignment, when you will move the scroll section then the left other images will show which are not visible at first. Each image contains, a title with a link, an author credit text, and a year.
So, Today I am sharing Horizontal Portfolio Layout Using jQuery and CSS Animation. There I have used jQuery for functioning and CSS for styling. As we know jQuery is a JS library, that’s why I am putting this post in the JavaScript category. You can use this program on your website in the portfolio section. After image change and some customization, this program is ready to place on your site.
If you are thinking now how this portfolio layout actually is, then see the preview given below.
Preview Of Image Portfolio Section
See this video preview to getting an idea of how this portfolio section looks like.
Now you can see this program visually, also you can see it live by pressing the button given above. If you like this, then get the source code of its.
You May Also Like:
- JavaScript Coverflow Slider
- Responsive Animated Gallery
- Smooth Accordion Dropdown
- Text Underline Hover Effect
Horizontal Portfolio Layout Source Code
Before sharing source code, let’s talk about it. First I have created the main div named container and placed all items inside it. Inside the main div, I have placed the image sections, all sections are based on the HTML list and inside each section I have placed an image, and 3 texts. Each section contains an image div, a title with a link, author text, and year. Also in the HTML file, I have linked external files like CSS, JS, and jQuery CDN.
Now using CSS I have placed all the elements in the right place, as you can see in the preview. With CSS I have done basic works like gave size, position, margin, padding, etc to the elements. For creating the animation effect I have used CSS @keyframe command and transform command. Also, I have used cubic-bezier command to define the animation curve.
jQuery handling here all the functions in the program. The main features in this program that are based on jQuery are scrolling to visible images, adding CSS class to animation, scroll to end image, etc. Left all other things you will understand after getting the codes, I can’t explain all in writing. For creating this program you have to create 3 files. First file for HTML, second file for CSS, and the third file for JavaScript.
Follow the steps to creating this program without any trouble.
index.html
Create an HTML file named ‘index.html‘ and put these codes given below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
<!DOCTYPE html> <!-- Code By Webdevtrick ( https://webdevtrick.com ) --> <html lang="en" > <head> <meta charset="UTF-8"> <title>Horizontal Portfolio Layout | Webdevtric.com</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js" type="text/javascript"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <ul class="portfolio-items"> <li class="item"> <figure> <div class="view"> <img src="https://webdevtrick.com/wp-content/uploads/image-upload-with-preview.jpg" /> </div> <figcaption> <p><span><a href="https://webdevtrick.com/image-upload-with-preview/">Image Upload & Preview</a></span></p> <p><span>By Webdevtrick</span></p> </figcaption> </figure> <div class="date">2019</div> </li> <li class="item"> <figure> <div class="view"> <img src="https://webdevtrick.com/wp-content/uploads/custom-select-dropdown-options.jpg" /> </div> <figcaption> <p><span><a href="https://webdevtrick.com/custom-select-dropdown-options/">Custom Select Dropdown</a></span></p> <p><span>By Webdevtrick</span></p> </figcaption> </figure> <div class="date">2019</div> </li> <li class="item"> <figure> <div class="view"> <img src="https://webdevtrick.com/wp-content/uploads/flex-hover-slider.jpg" /> </div> <figcaption> <p><span><a href="https://webdevtrick.com/flex-hover-slider/">Flex Hover Slider</a></span></p> <p><span>By Webdevtrick</span></p> </figcaption> </figure> <div class="date">2019</div> </li> <li class="item"> <figure> <div class="view"> <img src="https://webdevtrick.com/wp-content/uploads/jquery-circlular-image-slider.jpg" /> </div> <figcaption> <p><span><a href="https://webdevtrick.com/jquery-customized-circle-slider/">Circular Slider</a></span></p> <p><span>By Webdevtrick </span></p> </figcaption> </figure> <div class="date">2019</div> </li> <li class="item"> <figure> <div class="view"> <img src="https://webdevtrick.com/wp-content/uploads/javascript-coverflow-slider.jpg" /> </div> <figcaption> <p><span><a href="https://webdevtrick.com/javascript-coverflow-slider/">JS Coverflow Slider</a></span></p> <p><span>By Webdevtrick</span></p> </figcaption> </figure> <div class="date">2019</div> </li> <li class="item"> <figure> <div class="view"> <img src="https://webdevtrick.com/wp-content/uploads/3d-visualization-elements.jpg" /> </div> <figcaption> <p><span><a href="https://webdevtrick.com/3d-visualization-elements/">3D Visualization Elements</a></span></p> <p><span>By Webdevtrick</span></p> </figcaption> </figure> <div class="date">2019</div> </li> <li class="item"> <figure> <div class="view"> <img src="https://webdevtrick.com/wp-content/uploads/javascript-quote-slider.jpg" /> </div> <figcaption> <p><span><a href="https://webdevtrick.com/javascript-quote-slider/">Quote Slider</a></span></p> <p><span>By Webdevtrick</span></p> </figcaption> </figure> <div class="date">2019</div> </li> <li class="item"> <figure> <div class="view"> <img src="https://webdevtrick.com/wp-content/uploads/responsive-animated-gallery.jpg" /> </div> <figcaption> <p><span><a href="https://webdevtrick.com/responsive-animated-gallery/">Responsive Animated Gallery</a></span></p> <p><span>By Webdevtrick</span></p> </figcaption> </figure> <div class="date">2019</div> </li> <li class="item"> <figure> <div class="view"> <img src="https://webdevtrick.com/wp-content/uploads/password-strength-checker.jpg" /> </div> <figcaption> <p><span><a href="https://webdevtrick.com/jquery-password-strength-checker/">Password Strength Checker</a></span></p> <p><span>By Webdevtrick</span></p> </figcaption> </figure> <div class="date">2019</div> </li> <li class="item"> <figure> <div class="view"> <img src="https://webdevtrick.com/wp-content/uploads/css-feedback-star-rating.jpg" /> </div> <figcaption> <p><span><a href="https://webdevtrick.com/css-feedback-star-rating/">Feedback Rating</a></span></p> <p><span>By Webdevtrick </span></p> </figcaption> </figure> <div class="date">2019</div> </li> <li class="item"> <figure> <div class="view"> <img src="https://webdevtrick.com/wp-content/uploads/product-slider.jpg" /> </div> <figcaption> <p><span><a href="https://webdevtrick.com/fancybox-product-slider/">Fancybox Product Slider</a></span></p> <p><span>By Webdevtrick </span></p> </figcaption> </figure> <div class="date">2019</div> </li> <li class="item"> <figure> <div class="view"> <img src="https://webdevtrick.com/wp-content/uploads/css-segment-control.jpg" /> </div> <figcaption> <p><span><a href="https://webdevtrick.com/css-animated-segmented-control/">Segmented Control</a></span></p> <p><span>By Webdevtrick </span></p> </figcaption> </figure> <div class="date">2019</div> </li> <li class="item"> <figure> <div class="view"> <img src="https://webdevtrick.com/wp-content/uploads/javascript-rgb-slider.jpg" /> </div> <figcaption> <p><span><a href="https://webdevtrick.com/javascript-rgb-slider/">JavaScript RGB Slider</a></span></p> <p><span>By Webdevtrick </span></p> </figcaption> </figure> <div class="date">2019</div> </li> <li class="item"> <figure> <div class="view"> <img src="https://webdevtrick.com/wp-content/uploads/javascript-loan-calculator.jpg" /> </div> <figcaption> <p><span><a href="https://webdevtrick.com/javascript-loan-calculator/">Loan Calculator</a></span></p> <p><span>By Webdevtrick </span></p> </figcaption> </figure> <div class="date">2019</div> </li> <li class="item"> <figure> <div class="view"> <img src="https://webdevtrick.com/wp-content/uploads/full-page-navigation.jpg" /> </div> <figcaption> <p><span><a href="https://webdevtrick.com/css-full-page-navigation/">Full Page Navigation</a></span></p> <p><span>By Webdevtrick </span></p> </figcaption> </figure> <div class="date">2019</div> </li> </ul> </div> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src='https://raw.github.com/brandonaaron/jquery-mousewheel/master/jquery.mousewheel.js'></script> <script src="function.js"></script> </body> </html> |
style.css
Now create a CSS file named ‘style.css‘ and put these codes given here.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
/* Code By Webdevtrick ( https://webdevtrick.com ) */ @import url(https://fonts.googleapis.com/css?family=Lato:300,100,400); * { margin: 0; padding: 0; border: 0; box-sizing: border-box; position: relative; list-style-type: none } a { color: inherit; text-decoration: none } a.link { color: #C4290D } html, body { min-height: 100% } body { background: #eee; font: 300 20px/1.5 "Lato", sans-serif; color: #333 } .container { padding: 30px } .portfolio-items { height: 400px; overflow-x: scroll; overflow-y: hidden; white-space: nowrap; margin-bottom: 30px; position: relative } .portfolio-items > li { display: inline-block; vertical-align: top } .item { width: 300px; height: 202px; margin: 150px 20px 0; padding: 5px; border-radius: 2px; background-color: white; font-size: 14px; opacity: 0; position: relative; top: -300px; box-shadow: 0px 10px 10px -5px rgba(0,0,0,0.5); -webkit-transform: rotate(-135deg); -ms-transform: rotate(-135deg); -o-transform: rotate(-135deg); transform: rotate(-135deg); -webkit-transition: all .3s ease, opacity 2s ease, top 1s ease; -o-transition: all .3s ease, opacity 2s ease, top 1s ease; transition: all .3s ease, opacity 2s ease, top 1s ease } .item:nth-child(even) { margin-top: 100px } .item:hover { height: 270px; padding: 15px; -webkit-transform: translateY(-68px); -ms-transform: translateY(-68px); -o-transform: translateY(-68px); transform: translateY(-68px) } .item:hover .date { -webkit-transform: translate3d(0, 61px, 0); -ms-transform: translate3d(0, 61px, 0); -o-transform: translate3d(0, 61px, 0); transform: translate3d(0, 61px, 0) } .item:hover figcaption { -webkit-animation: show .25s ease-in .120s forwards; -o-animation: show .25s ease-in .120s forwards; animation: show .25s ease-in .120s forwards } .item:hover p:nth-of-type(1) span { -webkit-animation: slideOut .25s ease-out .15s forwards; -o-animation: slideOut .25s ease-out .15s forwards; animation: slideOut .25s ease-out .15s forwards } .item:hover p:nth-of-type(2) span { -webkit-animation: slideOut .2s ease-out .3s forwards; -o-animation: slideOut .2s ease-out .3s forwards; animation: slideOut .2s ease-out .3s forwards } .item:hover .view { height: 170px } .item:hover .view img { top: -20px; left: -20px; } .falldown { top: 0; opacity: 1; -webkit-transform: rotate(0); -ms-transform: rotate(0); -o-transform: rotate(0); transform: rotate(0) } figure { width: 100%; height: 100%; margin: 0; padding: 0; } .view { overflow: hidden; width: 100%; height: 190px; position: relative } .view img { width: 300px; height: 190px; -webkit-transition: width .3s ease; -o-transition: width .3s ease; transition: width .3s ease; position: absolute; } figcaption { height: 60px; width: 100%; padding: 0; position: absolute; bottom: 0; overflow: hidden; opacity: 0 } figcaption p { line-height: 25px !important; font: bold 12px/18px "Arial", sans-serif; text-transform: uppercase; padding: 0 10px; margin: 5px 0; width: 100%; background-color: #f0f0f0; color: #333 } figcaption span { left: -100%; opacity: 0 } figcaption a { color: #CC320F } .date { z-index: 1; width: 50px; height: 30px; line-height: 30px; color: #fff; font-weight: bold; text-align: center; border-radius: 1px; background-color: #CC320F; position: absolute; bottom: 30px; left: 15px; -webkit-transition: -webkit-transform 0.5s cubic-bezier(0.12, 1.6, 0.91, 0.92); -o-transition: -o-transform 0.5s cubic-bezier(0.12, 1.6, 0.91, 0.92); transition: -webkit-transform 0.5s cubic-bezier(0.12, 1.6, 0.91, 0.92); transition: -ms-transform 0.5s cubic-bezier(0.12, 1.6, 0.91, 0.92); transition: -o-transform 0.5s cubic-bezier(0.12, 1.6, 0.91, 0.92); transition: transform 0.5s cubic-bezier(0.12, 1.6, 0.91, 0.92) } @keyframes slideOut { 0% { left: -100%; opacity: 0 } 95% { left: 0; opacity: 0.2 } 100% { opacity: 1; left: 0 } } @keyframes show { to { opacity: 1 } } ::-webkit-scrollbar { width: 7px; height: 7px; cursor: pointer } ::-webkit-scrollbar-track { background-color: #ddd; border-radius: 10px } ::-webkit-scrollbar-thumb { border-radius: 10px; background-color: #C4290D } @-webkit-keyframes slideOut { 0% { left: -100%; opacity: 0 } 95% { left: 0; opacity: 0.2 } 100% { opacity: 1; left: 0 } } @-o-keyframes slideOut { 0% { left: -100%; opacity: 0 } 95% { left: 0; opacity: 0.2 } 100% { opacity: 1; left: 0 } } @-webkit-keyframes show { to { opacity: 1 } } @-o-keyframes show { to { opacity: 1 } } |
function.js
The last step, create a JavaScript file named ‘function.js‘ and put the codes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
// Code By Webdevtrick ( https://webdevtrick.com ) (function($) { var $window = $(window); $.fn.isVisible = function(){ var $this = $(this), Left = $this.offset().left, visibleWidth = $window .width(); return Left < visibleWidth; } })(jQuery); (function($){ var list = $('.portfolio-items'), showVisibleItems = function(){ list.children('.item:not(.falldown)').each(function(el, i){ var $this = $(this); if($this.isVisible()){ $this.addClass('falldown'); } }); }; //initially show all visible items before any scroll starts showVisibleItems(); //then on scroll check for visible items and show them list.scroll(function(){ showVisibleItems(); }); //image hover pan effect list.on('mousemove','img', function(ev){ var $this = $(this), posX = ev.pageX, posY = ev.pageY, data = $this.data('cache'); //cache necessary variables if(!data){ data = {}; data.marginTop = - parseInt($this.css('top')), data.marginLeft = - parseInt($this.css('left')), data.parent = $this.parent('.view'), $this.data('cache', data); } var originX = data.parent.offset().left, originY = data.parent.offset().top; //move image $this.css({ 'left': -( posX - originX ) / data.marginLeft, 'top' : -( posY - originY ) / data.marginTop }); }); list.on('mouseleave','.item', function(e){ $(this).find('img').css({ 'left': '0', 'top' : '0' }); }); list.mousewheel(function(event, delta) { this.scrollLeft -= (delta * 60); event.preventDefault(); }); })(jQuery); |
That’s It. Now you have successfully created Horizontal Portfolio Layout Using jQuery and CSS Animation. If you have any doubt or questions comment down below.
Thanks For Visiting, Keep Visiting.