add border only to the image when i hover a thumbnail - html

<div class='col-md-4'>
<div class="thumbnail">
<img src="media1/thumb3.jpg">
<div class="caption">
<h3>Lorem Ipsum</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
t</span>ΔΌ</span>
</div>
</div>
</div>
Here is my CSS
.thumbnail img{
width: 300px;
height: 300px;
border-radius: 150px;
}
.thumbnail {
border:none;
}
.thumbnail:hover {
background-color: #F2F3F4;
}
I would like to add border only to an image when i hover a thumbnail and not to the entire thumbnail (caption etc). Is there any way to do that using css ?

Give an id to the image say id="image"
And in the jquery use
<script>
$(document).ready(function(){
$('.thumbnail').mouseover(function(){
$('#image').css("border","2px solid black");
});});
$(document).ready(function(){
$('.thumbnail').mouseout(function(){
$('#image').css("border","0px");
});});
</script>
Do not forget to include the jquery script required to run jquery:-
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>

If you thumbnail div closes before img then you can do that. See this
On a CSS hover event, can I change another div's styling?

Just set this style:
.thumbnail:hover img {
border: solid 5px green;
margin: -5px;
}
The margin is to avoid the "changing position" effect
demo

If you want to change border on hover use :hover to the element in this case we will use this code
.thumbnail img:hover {
border: 3px solid #dddddd;
}
to control the changin position add a white border with same thickness to the normal state
.thumbnail img {
border: 3px solid #ffffff;
}
the complete code will be
.thumbnail img {
border: 3px solid #ffffff;
}
.thumbnail img:hover {
border: 3px solid #dddddd;
}

Related

Is there a way to move custom HTML scrollbar behind a div

I have some code snippets on my blog post here.
There I have custom scrollbar defined with this code below:
/* width */
::-webkit-scrollbar {
width: 20px;
}
/* Track */
::-webkit-scrollbar-track {
box-shadow: inset 0 0 5px grey;
border-radius: 10px;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: #0ef;
border-radius: 10px;
}
The place where I have included the snippet is a custom div element with border radius of 2em. Now the custom scrollbar looks some bulged out as you can see in the image below:
How can I send the scrollbar behind the <div> so that the extra scrollbar may be removed?
P.S.: The border radius of the <div> should be maintained.
You can put a small div inside your outer div and make that the container of your scroll bar to stop the bulging out of these scroll bars eg. fiddle like
<div class="outer">
<div class="inner">
..content
</div>
</div>
.outer{
max-height:200px;
width:250px;
border-radius:10px;
padding:0px 0px;
background:#ccc;
}
.inner{
white-space: nowrap;
width:250px;
max-height:200px;
overflow-x:scroll;
overflow-y:hidden;
border-radius:8px;
}
/* width */
::-webkit-scrollbar {
width: 20px;
}
/* Track */
::-webkit-scrollbar-track {
box-shadow: inset 0 0 5px grey;
border-radius: 10px;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: #0ef;
border-radius: 10px;
}
<div class="outer">
<div class="inner">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</div>
</div>

CSS multi-line ellipsis is not working in chrome

I've floating DIV on left side and right side ellipse div,
On mouse hover/out on left side div it is collapse/expand, in this case ellipses are not working.
I'm using two line ellipses
It is behaving differently based on content and window size
$(function() {
$(".left-content").mouseover(function() {
$(".left").width("30%");
}).mouseout(function() {
$(".left").width("50%");
});
})
div.left {
float: left;
border: solid 2px blue;
text-align: justify;
margin: 5px;
width: 50%;
overflow: hidden;
}
div.right {
float: left;
margin: 5px;
}
div.ellipses-twoline {
border: solid 2px blue;
width: 178px;
display: -webkit-box;
overflow: hidden;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
text-overflow: ellipsis;
box-sizing: border-box;
margin-bottom: 5px;
}
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.js"></script>
<div class="left">
<div class="left-content">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</div>
</div>
<div class="right">
<div class="ellipses-twoline">Located in Palm Springs and Santa Barbara, California, H3K Design specializes in design consultation and project management for house and building</div>
<div class="ellipses-twoline">
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help
</div>
</div>
View on JSFiddle

Fading an image into another image transition

I'm having a little difficulty getting this fade effect to work. I basically have two images on top of each other, and I have a hover effect that makes the opacity of the top image go to zero, which reveals the second image.
This effect is currently working when I have only one section. When I add another section, everything goes out of place. I suspect this has something to do with the fact that I'm using position: absolute, but I'm not sure how to go about fixing it.
I made a simple example to show you what is happening. This is what it looks like with one section (functional):
<body>
<header>
<h1>Projects</h1>
<h3>
Home | GitHub
</h3>
</header>
<hr>
<section>
<h2>Some project</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<div class="container">
<img class="main image" src="http://i.imgur.com/EkfA9Tl.png" alt="">
<img class="image" src="http://i.imgur.com/PWsXij1.png" alt="">
</div>
</section>
</body>
header {
text-align: center;
}
section {
width: 960px;
margin: 0 auto;
}
.container {
position: relative;
}
img {
position: absolute;
width: 650px;
height: 400px;
display: block;
}
.main {
z-index: 5;
transition: opacity .3s ease-in-out;
}
.main:hover {
opacity: 0;
}
You can see it here: http://jsfiddle.net/503dhw51/
When I try using two sections, the entire thing breaks. This is the code for two sections:
<body>
<header>
<h1>Projects</h1>
<h3>
Home | GitHub
</h3>
</header>
<hr>
<section>
<h2>Some project</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<div class="container">
<img class="main image" src="http://i.imgur.com/EkfA9Tl.png" alt="">
<img class="image" src="http://i.imgur.com/PWsXij1.png" alt="">
</div>
</section>
<section>
<h2>Some project</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<div class="container">
<img class="main image" src="http://i.imgur.com/EkfA9Tl.png" alt="">
<img class="image" src="http://i.imgur.com/PWsXij1.png" alt="">
</div>
</section>
</body>
and the CSS is the same.
Here is the jsfiddle for it: http://jsfiddle.net/5asgswxr/1/
I basically have two issues I need to fix:
Getting this to work for multiple sections
Somehow centering the images once I've fixed the first part
I would appreciate any help with either of these issues. Thanks in advance!
Here is my attempt. You can use this with other tags instead of images.
/*assures images to be of the same size*/
.frame { height: 300px; width:300px; }
/* code for effect you are looking for*/
figure { overflow: hidden; position: relative; border:solid lightgray 2px;}
.img1 { left: 0; position: absolute; right: 0; top: 0;
-webkit-transition: all 100ms ease-out;-moz-transition: all 500ms ease-out;transition: all 500ms ease-out;
border-radius: 5px 5px 5px 5px;-moz-border-radius: 5px 5px 5px 5px;-webkit-border-radius: 5px 5px 5px 5px;
}
.img1:hover { opacity: 0;}
/** important having things not "float" around*/
.clearfix:after { content: ".";display: block;clear: both;visibility: hidden;line-height: 0;height: 0;}
.clearfix { display: inline-block; }
html[xmlns] .clearfix { display: block; }
* html .clearfix { height: 1%; }
edit: Ahh.. I should have looked at the other submission before posting mine. Sorry.
As you suspected, the issue is that you are absolutely positioning all of the img elements. When an element is absolutely positioned, it is removed from the normal flow, resulting in other elements not taking it into consideration (thus, the overlap).
Since the .container element only contains absolutely positioned elements, it collapses upon itself and has a height of 0. To avoid this, one option would be to set an explicit height/width on the parent element.
Alternatively, the better option would be to only absolutely position a single img element. In doing so, the .container element will remain in the normal flow (because one of the img element's isn't removed from the flow). In this case, you could absolutely position the img element with class .main. In doing so, the other img element remains in the normal flow and defines the height/width of the parent, .containerelement.
Updated Example
.container {
position: relative;
}
.container img.main {
position: absolute;
}
For your second question (about centering), take a look at this updated example.

How to wrap text around image in HTML/CSS like MS Word does it when choosing "Top and Bottom"

I'm trying to implement the following text wrapping in HTML. I want the image to always appear below the first line of text, whatever the width of the page is.
Illustration:
And when the page is resized to be a bit narrower, it should look like this:
Basically the same way Word does it when you choose "Top and Bottom" in the image text wrapping options.
I'm pretty sure there's no built-in CSS feature for this layout. I think it could be implemented with text-measurements in JS - but it doesn't seem like a very elegant solution.
Any ideas?
Edit
The solution should also work for placing the at the n-th line, not just the first line.
This seems to work - FIDDLE.
CSS
.bigdiv {
border: 1px solid black;
width: 80%;
}
.picturediv {
width: 100%;
float: right;
}
.picturediv img {
width: 100%;
}
I've adapted TimSPQR's answer to allow placing the image on any line.
This is achieved by adding a narrow div that floats above the image, the line-height of which controls how many lines of text appear before the image.
HTML:
<div class='bigdiv'>
Lorem
<div class="clear">
</div>
<div class='picturediv'>
<img src='http://www.hdpaperwall.com/wp-content/uploads/2013/11/Mickey-Mouse-Wallpaper-disney-6628369-1024-768.jpg'/>
</div>
ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
CSS:
.bigdiv {
border: 1px solid black;
width: 80%;
line-height: 1em;
}
.picturediv {
width: 100%;
float: right;
}
.picturediv img {
width: 100%;
}
.clear
{
float: right;
line-height: 2em;
}
Fiddle

Detaching an element from document flow after positioning it

I have a div inside a td element with overflow:hidden set to it (the td). I want the inner div to be positioned in the document flow, and then detached from it so that it is allowed to overflow a little. How do I achieve that using CSS?
The HTML:
<table>
<tr>
<td id="projectDetails">
<div class="edit">
Edit
</div>
<span id="projectName">Project Name</span><br />
Category 1, Category 2<br />
<hr />
<span class="descriptor">Event Date</span>: 22/12/10 12:30<br />
<span class="descriptor">Event Location</span>: Technion, Haifa<br />
<span class="descriptor">Supervisor</span>: Yosi
</td>
<td id="projectDescription">
<div class="edit">
Edit
</div>
<span class="descriptor">Description</span>:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</td>
</tr>
</table>
The CSS:
table{
table-layout: fixed;
border-bottom: 1px solid;
width: 1008px;
}
td{
border-width: 0px solid;
vertical-align: top;
padding: 5px 5px 5px 5px;
}
#projectName{
font-size: 22px;
color: #892345;
}
td#projectDetails{
width: 350px;
border-right: 1px solid;
overflow: hidden;
}
Basically I want the "edit" div to be positioned at the top right of both td's, but in the projectDetails td to not be constrained by its overflow:hidden attribute.
you can remove the td from the document flow by using the position css attribute. This allows you to move the div around.
#projectDescription {
display: block;
position: relative;
top: 50px;
left: 50px;
}
example
but I'm not sure this is the best way to go about it.
A better way to go about it is to ditch the table, and do the layout using only divs and css, which would simplify your code, make it more readable, less confusing, and separate layout from content. I can post a simplified example if you'd like.