Message Boards
How do I add a link to the carousel images?
Tiago Machado, modified 5 Years ago.
How do I add a link to the carousel images?
Junior Member Posts: 59 Join Date: 2/21/19 Recent Posts
Hello friends,
I made a simple Carousel where I have 4 images, its working fine but I wanted to add some linking to the images, if I click in the image it should lead me to some page, for example google.com.
I tried a lot of things but none work
here is the code I have:
as you can see, I was trying to make a link to the image in the first carousel image, but its not working
thank you for your time
I made a simple Carousel where I have 4 images, its working fine but I wanted to add some linking to the images, if I click in the image it should lead me to some page, for example google.com.
I tried a lot of things but none work
here is the code I have:
<%@ include file="/init.jsp" %>
<%@ taglib prefix="aui" uri="http://liferay.com/tld/aui" %>
<div id="myCarousel">
<div class="image-viewer-base-image" align="center">
<a href="www.google.com">
<img src="http://localhost:8080/documents/20126/301163/sotc.jpg/c4862272-31e9-f945-29b6-9e3c807b0e94?t=1554131155303">
</a>
<!--
style="background: url(http://localhost:8080/documents/20126/301163/sotc.jpg/c4862272-31e9-f945-29b6-9e3c807b0e94?t=1554131155303);">
-->
</div>
<div class="image-viewer-base-image" align="center" style="background: url(http://localhost:8080/documents/20126/301163/sekiro.jpg/9b9c4d15-43fa-ae07-0527-1d4d14f6ca5f?t=1554131155554);">
</div>
<div class="image-viewer-base-image" align="center" style="background: url(http://localhost:8080/documents/20126/301163/dmc.jpeg/1deee1c2-bd97-5c71-5cba-3feeb6cd3767?t=1554131155678);">
</div>
<div class="image-viewer-base-image" align="center" style="background: url(http://localhost:8080/documents/20126/301163/kh_trailer_still_img.jpg/5eca8c8e-7b1f-741e-3787-21d6b7cc0e78?t=1554105748266);">
</div>
</div>
<aui:script>
YUI().use('aui-carousel', function(Y) {
new Y.Carousel({
activeIndex: 'rand',
contentBox: '#myCarousel',
height: 700,
intervalTime: 4,
width: 1175,
animationTime: 1.
}).render();
});
</aui:script>
as you can see, I was trying to make a link to the image in the first carousel image, but its not working
thank you for your time
Tiago Machado, modified 5 Years ago.
RE: How do I add a link to the carousel images?
Junior Member Posts: 59 Join Date: 2/21/19 Recent Posts
I couln't do it that way so I found a useful page that helped me a lot doing my clickable carousel.
for those who need it: https://codepen.io/JacobLett/pen/PjKLgK
Just need to make the changes to what you need to display, and import the css using :
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/main.css" />
that works fine, hope it helps those in need.
for those who need it: https://codepen.io/JacobLett/pen/PjKLgK
Just need to make the changes to what you need to display, and import the css using :
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/main.css" />
that works fine, hope it helps those in need.