Image gallery without borders? - html

I have been trying to do an image gallery for my portfolio but I want them images without borders and next to each other both horizontally and Vertically. Unfortunately All my attempts have been unsuccessful.
.portfolio {
height: 1250px;
width: 80%;
margin: 0 auto;
background-color: #CF9;
}
#thumbs {
width: 20%;
height: 50px;
color: #090;
float: left;
font-size: 0px;
}
<div class="portfolio">
<div id="thumbs">
<a href="http">
<img src="thumb.png">
</a>
</div>
<div id="thumbs">
<a href="http">
<img src="thumb.png">
</a>
</div>
<div id="thumbs">
<a href="http">
<img src="thumb.png">
</a>
</div>
<div id="thumbs">
<a href="http">
<img src="thumb.png">
</a>
</div>
<div id="thumbs">
<a href="http">
<img src="thumb.png">
</a>
</div>
<div id="thumbs">
<a href="http">
<img src="thumb.png">
</a>
</div>
<div id="thumbs">
<a href="http">
<img src="thumb.png">
</a>
</div>
<div id="thumbs">
<a href="http">
<img src="thumb.png">
</a>
</div>
<div id="thumbs">
<a href="http">
<img src="thumb.png">
</a>
</div>
<div id="thumbs">
<a href="http">
<img src="thumb.png">
</a>
</div>
</div>
http://www.adhemas.com/ is kind of what I'm trying to achieve, except my images are all the same size (although I would not mind a how to make them different sizes but still stacked)

Element IDs should be unique within your entire document. If you have more than one element with the same ID, your HTML is invalid, which is likely to cause your web page to stop working as intended.
Source: Can multiple different HTML elements have the same ID if they're different types?
I suggest you use classes instead, which support having multiple elements with the same class.
Give all your elements a class of thumbs instead of an id. Then you can use .thumbs instead of #thumbs in your CSS rule to style your elements.

First thing to fix is the id. You cannot reuse the id in the html.
Next you need to set the a and the img to be constrained inside the .thumb element.
Something like the following
.portfolio {
height: 1250px;
width: 80%;
margin: 0 auto;
background-color: #CF9;
}
.thumbs {
width: 20%;
color: #090;
float: left;
font-size: 0px;
}
.thumbs a {display:block;}
.thumbs img{width:100%;}
<div class="portfolio">
<div class="thumbs">
<a href="http">
<img src="http://lorempixel.com/500/500/cats/1">
</a>
</div>
<div class="thumbs">
<a href="http">
<img src="http://lorempixel.com/500/500/cats/2">
</a>
</div>
<div class="thumbs">
<a href="http">
<img src="http://lorempixel.com/500/500/cats/3">
</a>
</div>
<div class="thumbs">
<a href="http">
<img src="http://lorempixel.com/500/500/cats/4">
</a>
</div>
<div class="thumbs">
<a href="http">
<img src="http://lorempixel.com/500/500/cats/5">
</a>
</div>
<div class="thumbs">
<a href="http">
<img src="http://lorempixel.com/500/500/cats/6">
</a>
</div>
<div class="thumbs">
<a href="http">
<img src="http://lorempixel.com/500/500/cats/7">
</a>
</div>
<div class="thumbs">
<a href="http">
<img src="http://lorempixel.com/500/500/cats/8">
</a>
</div>
<div class="thumbs">
<a href="http">
<img src="http://lorempixel.com/500/500/cats/9">
</a>
</div>
<div class="thumbs">
<a href="http">
<img src="http://lorempixel.com/500/500/cats/10">
</a>
</div>
</div>

Removing the <div> tags completely and setting the <img> CLASS (don't use ID's more than once) to thumbs stacks the images nicely next to each other with no margins (thanks to your left float). Unless there's a reason to keep the <div>'s I suggest removing them as they're just in the way, they're also block elements which goes against the inline layout you're after.

Related

Select specific element with CSS

I'm trying to select title with CSS selector.
This is my css
.category-center :nth-last-child(-n+2) {
color: red;
}
<div class="category-center">
<div class="cbp-item-wrapper">
<div class="post-medias">
<a href="" target="_blank">
<img src="#" alt="">
</a>
</div>
<div class="post-info">
<h4 class="post-title">
This is awesome title
</h4>
</div>
</div>
</div>
Can somebody help me with this?
You can use .category-center .post-title a. It will target the <a> element which is inside the element with class post-title which is inside category-center element.
You could even use .post-title a but it will break the hierarchy of CSS which you already have for elements inside .category-center. Also, it will tightly bound the HTML with CSS so when in future if you place the HTML outside of .category-center then the styles will not apply and you will know that something is going wrong with that action.
.category-center .post-title a {
color: red;
}
<div class="category-center">
<div class="cbp-item-wrapper">
<div class="post-medias">
<a href="" target="_blank">
<img src="#" alt="">
</a>
</div>
<div class="post-info">
<h4 class="post-title">This is awesome title</h4>
</div>
</div>
<div class="cbp-item-wrapper">
<div class="post-medias">
<a href="" target="_blank">
<img src="#" alt="">
</a>
</div>
<div class="post-info">
<h4 class="post-title">This is awesome title</h4>
</div>
</div>
<div class="cbp-item-wrapper">
<div class="post-medias">
<a href="" target="_blank">
<img src="#" alt="">
</a>
</div>
<div class="post-info">
<h4 class="post-title">This is awesome title</h4>
</div>
</div>
</div>
Just target the class rather than going specific numnber of children in, as this means if you change your page redesign slightly, it will no longer work.
You can either put a class on your a tag, or target any a tag, on your h4 class, as below.
.post-title a {
color: red;
}
<div class="category-center">
<div class="cbp-item-wrapper">
<div class="post-medias">
<a href="" target="_blank">
<img src="#" alt="">
</a>
</div>
<div class="post-info">
<h4 class="post-title">This is awesome title</h4>
</div>
</div>
</div>

Put images next to each other

HTML
<div class="button">
<a href="#">
<img id="img1" src="icons/onas1.svg" alt="O nas[enter image description here][1]">
</>
<a href="#">
<img id="img2" src="icons/kontakt1.svg" alt="kontakt">
</a>
</div>
</div>
CSS:
div.button img{
position: fixed;
height: 10%;
display: inline-block;
}
Hey, how can I put these two images next to each other?
Try this code:
div a img{
height: 10%;
width:200px;
}
<div class="button">
<a href="#">
<img id="img1" src="https://yt3.ggpht.com/-3N3L1JNdZ4k/AAAAAAAAAAI/AAAAAAAAAAA/PmHzBEEHaU4/s900-c-k-no-mo-rj-c0xffffff/photo.jpg" alt="O nas[enter image description here][1]">
</>
<a href="#">
<img id="img2" src="https://yt3.ggpht.com/-3N3L1JNdZ4k/AAAAAAAAAAI/AAAAAAAAAAA/PmHzBEEHaU4/s900-c-k-no-mo-rj-c0xffffff/photo.jpg" alt="kontakt">
</a>
</div>
</div>

how to set different background shape when hover on image?

I have created three images in column, and i set
column-count: 3;
And i set border-width for those three images. Now i need to know about hover state.
Html:
<div class="wrap">
<h1 class="content-title">
<span>Popular</span>
</h1>
<div class="col-3">
<div class="popular">
<a href="#">
<img src="http://s7.postimg.org/bq6aahcpn/Book_ll_4.jpg" />
</a>
</div>
<div class="caption"><h2>Saina nehwal first match</h2><p>fasdfjaksdksdfh skdfk</p>
</div>
<div class="popular">
<a href="#">
<img src="http://s7.postimg.org/bq6aahcpn/Book_ll_4.jpg" />
</a>
</div>
<div class="caption"><h2>Saina nehwal first match</h2><p>fasdfjaksdksdfh skdfk</p>
</div>
<div class="popular">
<a href="#">
<img src="http://s7.postimg.org/bq6aahcpn/Book_ll_4.jpg" />
</a>
</div>
<div class="caption"><h2>Saina nehwal first match</h2><p>fasdfjaksdksdfh skdfk</p>
</div>
</div>
</div>
When i hover an image, It need to show like this
And here is my worked jsfiddle: http://jsfiddle.net/6g7v899q/
I need something like this [can you please refer this site gatesnotes.com in reading post part?.. I need like this.. ]
May i know, how to do this?
Thanks in advance.
This can be possible with the width and color of the borders on the box, the page you refer has this styles:
.hpunit .hpimgrel .hpbook:hover .gbox {
border-left: 59px solid #ddd;
border-right: 59px solid #ddd;
}
In your code can be like this:
.popular {
display:inline-block;
border:40px solid #eee;
box-sizing:border-box;
}
.popular:hover {
border-left:40px solid gray;
border-right:40px solid gray;
}
<div class="wrap">
<h1 class="content-title">
<span>Popular</span>
</h1>
<div class="col-3">
<div class="popular">
<a href="#">
<img src="http://s7.postimg.org/bq6aahcpn/Book_ll_4.jpg" />
</a>
</div>
<div class="caption"><h2>Saina nehwal first match</h2><p>fasdfjaksdksdfh skdfk</p>
</div>
<div class="popular">
<a href="#">
<img src="http://s7.postimg.org/bq6aahcpn/Book_ll_4.jpg" />
</a>
</div>
<div class="caption"><h2>Saina nehwal first match</h2><p>fasdfjaksdksdfh skdfk</p>
</div>
<div class="popular">
<a href="#">
<img src="http://s7.postimg.org/bq6aahcpn/Book_ll_4.jpg" />
</a>
</div>
<div class="caption"><h2>Saina nehwal first match</h2><p>fasdfjaksdksdfh skdfk</p>
</div>
</div>
</div>

How to set different shape color when hover state of image?

I have created three images in a column and I set column-count: 3; plus border-width for those three images. Now I need to know about the hover state.
HTML:
<div class="wrap">
<h1 class="content-title"><span>Popular</span></h1>
<div class="col-3">
<div class="popular">
<a href="#">
<img src="http://s7.postimg.org/bq6aahcpn/Book_ll_4.jpg"/>
</a>
</div>
<div class="caption">
<a href="olymbic.html">
<h2>Saina nehwal first match</h2>
<p>fasdfjaksdksdfh skdfk</p>
</a>
</div>
<div class="popular">
<a href="#">
<img src="http://s7.postimg.org/bq6aahcpn/Book_ll_4.jpg"/>
</a>
</div>
<div class="caption">
<a href="#">
<h2>Saina nehwal first match</h2>
<p>fasdfjaksdksdfh skdfk</p>
</a>
</div>
<div class="popular">
<a href="#">
<img src="http://s7.postimg.org/bq6aahcpn/Book_ll_4.jpg"/>
</a>
</div>
<div class="caption">
<a href="#">
<h2>Saina nehwal first match</h2>
<p>fasdfjaksdksdfh skdfk</p>
</a>
</div>
</div>
</div>
When I hover an image, it needs to look like this:
.
And here is my jsfiddle: http://jsfiddle.net/6g7v899q/
May I know, how to do this?
Thanks in advance.
something like this then ?
img{margin:40px;border:25px solid white;}
img:hover{border-left:25px inset gray;border-right:25px outset gray;border-top:25px outset white;border-bottom:25px inset white;}
<img src="http://lorempixel.com/200/200" width="200" height="200" />

Image high resolution not resizing fit to div

I found many topics but I still have yet to find solution for my issue. When using image src from lorempixel, my code works well but when using image local (4000x3000), it not resizing to fit the div. Hope anyone can help me.
I'm using Bootstrap 3.1.1
HTML
<section class="portfolio">
<div class="portfolio-list">
<ul>
<li>
<div class="portfolio-box">
<a href="#">
<img src="img/thumb-1.jpg" alt="Portfolio item">
</a>
</div>
</li>
<li>
<div class="portfolio-box">
<a href="#">
<img src="http://lorempixel.com/598/386/" alt="Portfolio item">
</a>
</div>
</li>
<li>
<div class="portfolio-box">
<a href="#">
<img src="http://lorempixel.com/598/386/" alt="Portfolio item">
</a>
</div>
</li>
<li>
<div class="portfolio-box">
<a href="#">
<img src="http://lorempixel.com/598/386/" alt="Portfolio item">
</a>
</div>
</li>
<li>
<div class="portfolio-box">
<a href="#">
<img src="http://lorempixel.com/598/386/" alt="Portfolio item">
</a>
</div>
</li>
<li>
<div class="portfolio-box">
<a href="#">
<img src="http://lorempixel.com/598/386/" alt="Portfolio item">
</a>
</div>
</li>
</ul>
</div> <!-- end portfolio-list -->
</section> <!-- end portfolio -->
CSS
.portfolio-list{
background-color: #cccccc;
li{
float: left;
width: 33.33%;
display: block;
}
}
http://jsfiddle.net/2mbsb16m/
You should be setting the images immediate parent elements width and height. Then you can set the image to width:100%: height:auto;
.portfolio-box {
width:300px;
height:300px;
}
.portfolio-box img {
width:100%;
height:auto;
}
Updated fiddle: http://jsfiddle.net/donnellyjoe/2mbsb16m/2/