In a site I'm developing, I have a bunch of different sized images laid out in a horizontal layout. I have some named anchor links that jump to specific images when clicked, too. If a click on the links, I need that the selected image to be in the center of the page, not at the end. Is there any way to add some negative offset to the anchors?
Thanks in advance
HTML:
<a href="#item-9">Link to item 9</a>
<div class="carousel-frame">
<ul>
<li id="item-1" class="carousel-item">
<span>1</span>
<img src="http://placehold.it/200x150" />
</li>
<li id="item-2" class="carousel-item">
<span>2</span>
<img src="http://placehold.it/200x150" />
</li>
<li id="item-3" class="carousel-item">
<span>3</span>
<img src="http://placehold.it/200x150" />
</li>
<li id="item-4" class="carousel-item">
<span>4</span>
<img src="http://placehold.it/200x150" />
</li>
<li id="item-5" class="carousel-item">
<span>5</span>
<img src="http://placehold.it/200x150" />
</li>
<li id="item-6" class="carousel-item">
<span>6</span>
<img src="http://placehold.it/200x150" />
</li>
<li id="item-7" class="carousel-item">
<span>7</span>
<img src="http://placehold.it/200x150" />
</li>
<li id="item-8" class="carousel-item">
<span>8</span>
<img src="http://placehold.it/200x150" />
</li>
<li id="item-9" class="carousel-item">
<span>9</span>
<img src="http://placehold.it/200x150" />
</li>
<li id="item-10" class="carousel-item">
<span>10</span>
<img src="http://placehold.it/200x150" />
</li>
<li id="item-11" class="carousel-item">
<span>11</span>
<img src="http://placehold.it/200x150" />
</li>
<li id="item-12" class="carousel-item">
<span>12</span>
<img src="http://placehold.it/200x150" />
</li>
<li id="item-13" class="carousel-item">
<span>13</span>
<img src="http://placehold.it/200x150" />
</li>
<li id="item-14" class="carousel-item">
<span>14</span>
<img src="http://placehold.it/200x150" />
</li>
<li id="item-15" class="carousel-item">
<span>15</span>
<img src="http://placehold.it/200x150" />
</li>
<li id="item-16" class="carousel-item">
<span>16</span>
<img src="http://placehold.it/200x150" />
</li>
</ul>
</div>
CSS:
.carousel-frame {
width: 100%;
margin-bottom: 0.5em;
padding-bottom: 1em;
position: relative;
white-space: nowrap;
}
.carousel-frame ul {
margin: 0;
padding: 0;
height: 100%;
list-style: none;
}
.carousel-frame li.carousel-item {
cursor: pointer;
display: inline-block;
margin: 0 5px 0 0;
padding: 0;
}
.carousel-frame li.carousel-item span {
display: block;
}
Here's a fiddle:
You can use animate: