Centralized Text over an Image on Mouse Over - css

I've been trying to achieve the effect of mouse over on a picture which dims its background and brings over a text on top.
Then I wanted a nice centralized text when I moused over.
These both things were achieved, but then I ran into a small problems.
How can I centralized the text without specifying width and height of the picture (to enable responsive design)
The Problem is that If I specify the width/Height, it would show the text perfectly centered, but when I change the page dimensions, it loses the center point.
HTML
<div id="bottomWide">
<ul>
<li class="first">
<img src="http://127.0.0.1/www/media/wysiwyg/sub-head1.jpg" alt="">
<div class="all-canvas">
<div class="all-text">
<span class="title">A Heading</span><br>
<span class="text">Couples of Lines of Text will come here</span><br>
<span class="shop">See Details.</span>
</div>
</div>
</li>
<li class="second">
<img src="http://127.0.0.1/www/media/wysiwyg/sub-head1.jpg" alt="">
<div class="all-canvas">
<div class="all-text">
Some text here, style as needed
</div>
</div>
</li>
</ul>
</div>
CSS
#bottomWide{
width:100%;
margin:0 auto;
}
#bottomWide ul{
margin:0;
padding:0;
}
#bottomWide li{
list-style-type: none;
display: inline-block;
width:50%;
text-align:justify;
float: left;
/* For Mouse Over*/
position: relative;
display: inline-block;
}
#bottomWide li:last-child img {
border-left: 4px solid #fff;
}
#bottomWide img{
width:100%;
}
#bottomWide li div.all-canvas{
position: absolute;
top: 0;
left: 0;
/* 100% will equal the dimensions of the image, as nothing else will be inside the .container */
width: 100%;
height: 100%;
color: #fff;
background-color: #000;
opacity: 0;
/* This will create the fade effect */
transition: opacity 0.3s;
-webkit-transition: opacity 0.3s;
/* Include all required vendor prefixes for opacity and transition */
margin: 0 auto;
}
#bottomWide li:last-child div.all-canvas {
margin-left: 4px;
}
#bottomWide li div.all-canvas:hover {
opacity: 0.7;
}
#bottomWide li:last-child div.all-canvas:hover {
opacity: 0.7;
margin-left: 4px;
}
div.all-text {
height:358px; /* This is what I want to change to %*/
width: 623px; /* This is what I want to change to %*/
text-align:center;
border:1px solid silver;
display: table-cell;
vertical-align:middle;
margin: 0 auto;
}
div.all-text span.title { padding: 3px; font: 18px/1.35 "Open Sans", Helvetica, sans-serif; text-transform: uppercase;}
Thanks.

Related

Angular *ngFor li - how to set item width of two items width?

i have a *ngFor that fill my page with items.
within the ngFor i have banners that i want to display.
but the banners width is different from the other items.
so the banner is clickable only within the width of the original li width.
a half of the banner is just displayed but i can not click on it.
i think the problem is because the other items height is get bigger if banner is showed.
the li original sizes is 200X250 px
and when a banner is showed up the li sizes changed to 200X400.
(the banner height is added to the other items height)
blue = banner
red = clickable
green = unclickable
<ul class="row">
<li
*ngFor="let fav of favoriteLessons2; let i = index"
class="col-12 col-sm-6 col-md-4 col-xl-4">
<div class="item pointer">
<jt-lesson-item
[lesson]="fav"
[userLessonId]="fav.id"
[lessonType]="true">
</jt-lesson-item>
<p-progressBar
class="customProgress"
[value]="func(favoriteLessons[i]) | number:'1.0-0'">
</p-progressBar>
</div>
<div
class="banner pointer"
*ngIf="i > 0 && i%counter==0">
<jt-ngui-in-view
[once]="true"
(inView)="updateBannerWatched(bannersArray[bannerIndex(i)])">
<ng-template>
<img
(click)="updateBannerClicked(bannersArray[bannerIndex(i)])"
[src]="bannersArray[bannerIndex(i)].imageUrl"
(click)="bennerPressed(bannersArray[bannerIndex(i)].id)">
</ng-template>
</jt-ngui-in-view>
</div>
</li>
</ul>
how can i handle this issue ?
thank you !
Edited:
css code :
ul{
text-align: center;
direction: rtl;
height:100%;
padding-top: 40px;
padding-right: 90px;
}
li{
width:100%;
max-width: 200px;
list-style: none;
direction: rtl;
text-align: right;
// display: inline-block;
margin:10px;
padding:10px;
&.banner {
width:100%;
display: block;
padding: 10px;
margin-top:10px;
}
}
img{
display: block;
margin: 10px;
padding-top: 23px;
}
.item{
background-color: #FFF;
border-radius: 4px;
width:200px;
&:hover{
background: rgba(23, 23, 23, 0.8);
border-radius: 4px;
bottom: -4px;
color: #000;
left: -4px;
right: -4px;
top: -4px;
display: block;
opacity: 20;
z-index: 1;
transition-property: all;
transition-duration: 0.2s;
transition-timing-function: ease;
transition-delay: 0s;
padding:1px;
border-radius: 4px;
background-color: rgb(243, 243, 243);
}
}

CSS positioning issue for chat conversation

I'm having issues with my CSS positioning for a conversation/chat page. Please see the code in this fiddle for my first attempt: https://jsfiddle.net/1gsykwL5/
Is there any way to make the div containing the 'logo' 100% height, so that the text (message) doesn't wrap underneath it? I've played around with position: absolute but it really screws up alignment.
I think there's probably a better way of coding it to be honest. But I'm not sure how. Can anybody please advise?
Thanks!
PS - code which includes the padding fix by Rick Jelier:
body{
font-family:arial;
}
.newchat {
padding: 10px;
}
.newdiv1 {
width: 50px;
height:100%;
float: left;
margin: 0px 10px 10px 0px;
}
.chat2 ul{
list-style: none;
padding:0px;
}
.chat2 ul li
{
border-radius: 5px;
}
.chat2 ul li:hover .thumbnail {
background: #bd6982;
}
.chat2 ul li .thumbnail {
display: inline-block;
background: #bfbfbf;
width: 50px;
color: #ffffff;
line-height: 50px;
text-align: center;
text-decoration: none;
-webkit-transition: background 0.3s linear 0s;
-moz-transition: background 0.3s linear 0s;
-ms-transition: background 0.3s linear 0s;
-o-transition: background 0.3s linear 0s;
transition: background 0.3s linear 0s;
border-radius: 50%;
}
.chat2 ul li:nth-child(2n) {
background: #f2f2f2;
}
.newdiv2 .meta {
color: #b3b3b3;
font-size: 12px;
padding-left: 60px;
}
.newdiv2 .meta a:hover {
text-decoration: underline;
}
.newdiv2 .meta a {
color: #999999;
text-decoration: none;
}
.newdiv2 h3 {
font-size:14px;
display: block;
width: 100%;
margin: 0px 0px 5px 0px;
color: #808080;
}
.newdiv2
{
font-size:12px;
color: #cccccc;
}
.newdiv2 .preview
{
display:block;
margin-bottom: 5px;
padding-left: 60px;
}
.otherUser
{
margin-left:30px;
}
<div class="chat2">
<ul>
<li>
<div class="newchat">
<div class="newdiv2">
<div class="newdiv1">
<a class="thumbnail" href="#">KS</a>
</div>
<h3>Kenny Sing</h3>
<span class="preview">make sure you take a look at the... ashiud hiuas hdiu huio hiu hiuo hiu hiu hio uhoiu hoi hui hoiouh
idsh ifu hisuod hfoiu hidsu hiu fhiuo dshiu hiuo hiou hiu hoiuhiohiuo hiu ohi uhiou hi ouhi iusdh fius dhuif hsdiuf hisdu fhusid f2f2f2 siudphf uisd h
osih doifh sidoh fiusd hiuf hdsiu hiu hiu</span>
<div class="meta">3h ago · Category · Reply</div>
</div>
</div>
</li>
<li class="otherUser">
<div class="newchat">
<div class="newdiv2">
<div class="newdiv1">
<a class="thumbnail" href="#">KS</a>
</div>
<h3>Kenny Sing</h3>
<span class="preview">make sure you take a look at the... ashiud hiuas hdiu huio hiu hiuo hiu hiu hio uhoiu hoi hui hoiouh
idsh ifu hisuod hfoiu hidsu hiu fhiuo dshiu hiuo hiou hiu hoiuhiohiuo hiu ohi uhiou hi ouhi</span>
<div class="meta">3h ago · Category · Reply</div>
</div>
</div>
</li>
</ul>
</div>
Try adding 60px of padding to the left of the textbox itself:
.newdiv2 .preview {
/* current css */
padding-left: 60px;
}
I tried it in the jsfiddle and it seems to work.
Hope this helps!
I see it in two ways:
position absolute of logo (+ top:10px, left:10px), and padding left + position relative to the container - with padding it shouldn't screw up your your alignment
or
Padding to the message container and negative margin to the logo
.newchat {
padding-left: 70px;
}
.newdiv1 {
margin: 0px 10px 10px -60px;
}
Less code more fun
Since you asked for leaner markup, this is how I'd approach it:
body {
background-color: #333;
}
.chat {
list-style-type: none;
}
.meta-message {
display: block;
color: #999;
margin-top: 5px;
}
.sender-message,
.reply-message {
background-color: #fff;
border-radius: 15px;
display: block;
font-family: sans-serif;
font-size: 20px;
line-height: 1.25;
max-width: 400px;
margin-bottom: 15px;
min-height: 60px;
padding: 15px 15px 15px 80px;
position: relative;
}
.sender-message::before,
.reply-message::before {
content: attr(data-shortname);
display: inline-block;
width: 50px;
height: 50px;
line-height: 50px;
position: absolute;
left: 15px;
top: 15px;
background-color: #a00;
text-align: center;
border-radius: 50%;
color: #fff;
}
.sender-message .name,
.reply-message .name {
color: #a00;
font-size: 28px;
margin: 0;
text-align: right;
}
.reply-message {
background-color: #eee;
margin-left: 80px;
}
.reply-message .name {
color: #0a0;
}
.reply-message::before {
background-color: #0a0;
}
<ol class="chat">
<li class="sender-message" data-shortname="kk">
<h3 class="name">Kenny King</h3>Is there any way to make the div containing the 'logo' 100% height, so that the text (message) doesn't wrap underneath it? I've played around with position: absolute but it really screws up alignment.<span class="meta-message">2016/12/13 12:41 p.m.</span>
</li>
<li class="reply-message" data-shortname="cw">
<h3 class="name">connexo websolutions</h3>Let's see how far we can get from a small codepen snippet...<span class="meta-message">2016/12/13 12:42 p.m.</span>
</li>
</ol>
https://codepen.io/connexo/pen/eBPXbd
Why did I use an ol?
Because a chat consists of a (typically chronologically) ordered list of messages (where order does matter).
I think you will be able to start from here and get to where you want to go.

css <hr class="divider"> responsive

Problem is about , it works great on desktop but on mobile fails....
[http://jsfiddle.net/9vv914uL/][1]
i want to make this divider responsive... because it is working very well on higher resolutions , as you can see....
and bonus is to make words inside tag in different colors...
this is css stylesheet:
.divider {
text-align:center;
font-family: 'montserrat';
}
.divider hr {
margin-left:auto;
margin-right:auto;
width:40%;
}
.left {
float:left;
}
.right {
float:right;
}
this is
<div style="padding-top:10px; padding-bottom:20px;"class="divider">
<hr class="left" style="margin-top:12px;"/>BLUE RED<hr class="right" style="margin-top:12px;"/>
</div>
I dont know what to say about this problem, this is just plain text. I must go back to the stars <3
:)
There are other ways that this can be handled that would work better for what you are trying to do. In my example, I am using both a heading element and an empty div. The text in the heading element can be expanded as much as you would like without needing to worry about available space, and the solution is responsive out of the box.
HTML
<h3 class="divider">
<span>Title</span>
</h3>
<div class="divider">
<span></span>
</div>
CSS
.divider {
border-color: #000;
border-style: solid;
border-width: 0 0 1px;
height: 10px;
line-height: 20px;
text-align:center;
overflow: visable;
}
.divider span {
background-color: #FFF;
display: inline-block;
padding: 0 10px;
min-height: 20px;
min-width: 10%;
}
Fiddle: http://jsfiddle.net/6uux0cbn/1/
I'd probably do it like this rather than messing with floats:
.divider {
text-align: center;
}
.divider:after {
content: "";
height: 1px;
background: #000;
display: block;
position: relative;
top: -8px; /* this value depends on the font size */
}
.divider > span {
background: #fff;
padding: 0 10px;
position: relative;
z-index: 1;
}
<div class="divider"><span>BLUE RED</span></div>
HTML:
<div style="padding-top:10px; padding-bottom:20px;"class="divider">
<hr class="left" style="margin-top:12px;"/>
<div class="title">BLUE RED</div>
</div>
CSS:
.divider {
text-align:center;
font-family: 'montserrat';
position:relative;
height: 68px;
}
.div hr {
width:100%;
position: absolute;
z-index: 888;
}
.title {
position: absolute;
left:50%;
width:100px;
margin-left: -50px;
z-index: 9999;
top:15px;
background: white;
}

Working with hover background Change on a DIV

I've been trying to achieve the effect of mouse over on a picture which dims its background and brings over a text on top.
Then I wanted a nice centralized text when I moused over.
These both things were achieved, but then I ran into two small problems.
How can I not dim the text on top when I dim the background of the picture
How can I centralized the text without specifying width and height of the picture (to enable responsive design)
HTML
<div id="bottomWide">
<ul>
<li class="first">
<img src="http://127.0.0.1/www/media/wysiwyg/sub-head1.jpg" alt="">
<div class="all-canvas">
<div class="all-text">
<span class="title">A Heading</span><br>
<span class="text">Couples of Lines of Text will come here</span><br>
<span class="shop">See Details.</span>
</div>
</div>
</li>
<li class="second">
<img src="http://127.0.0.1/www/media/wysiwyg/sub-head1.jpg" alt="">
<div class="all-canvas">
<div class="all-text">
Some text here, style as needed
</div>
</div>
</li>
</ul>
</div>
CSS
#bottomWide{
width:100%;
margin:0 auto;
}
#bottomWide ul{
margin:0;
padding:0;
}
#bottomWide li{
list-style-type: none;
display: inline-block;
width:50%;
text-align:justify;
float: left;
/* For Mouse Over*/
position: relative;
display: inline-block;
}
#bottomWide li:last-child img {
border-left: 4px solid #fff;
}
#bottomWide img{
width:100%;
}
#bottomWide li div.all-canvas{
position: absolute;
top: 0;
left: 0;
/* 100% will equal the dimensions of the image, as nothing else will be inside the .container */
width: 100%;
height: 100%;
color: #fff;
background-color: #000;
opacity: 0;
/* This will create the fade effect */
transition: opacity 0.3s;
-webkit-transition: opacity 0.3s;
/* Include all required vendor prefixes for opacity and transition */
margin: 0 auto;
}
#bottomWide li:last-child div.all-canvas {
margin-left: 4px;
}
#bottomWide li div.all-canvas:hover {
opacity: 0.7;
}
#bottomWide li:last-child div.all-canvas:hover {
opacity: 0.7;
margin-left: 4px;
}
div.all-text {
height:358px; /* This is what I want to change to %*/
width: 623px; /* This is what I want to change to %*/
text-align:center;
border:1px solid silver;
display: table-cell;
vertical-align:middle;
margin: 0 auto;
}
div.all-text span.title { padding: 3px; font: 18px/1.35 "Open Sans", Helvetica, sans-serif; text-transform: uppercase;}
The Output looks something like this:-
(Notice the dim text on top of the picture; hoping to make it solid)
Thanks.
If you set opacity to an element, all children (including the text) will have the opacity as well. You could try changing the background color using rgba:
#bottomWide li div.all-canvas:hover {
background-color: rgba(0,0,0, 0.7);
}
You'll still need to toggle opacity 0 to 1 so it can become visible, but the background-color should be transparent.
Centering the text will be a lot more tricky because you're trying to make it responsive. Since the text won't have a fixed height, you will probably have to use Javascript to calculate it. You could start with this CSS:
.theText {
position: absolute;
top: 50%;
margin-top: -20px; // Should be half of the element height
}
You'll have to use javascript to measure the height of .theText and set a negative margin-top accordingly...

Connect two elements keeping responsive value

I am creating a simple real estate website and am currently creating the listing page. I would like a product very similar to this here. I cannot gain ideas from the code because I am using the skeleton framework. This is my current progress and code or below.
The two elements; photo of property and body of text are apart (there's a gap in the middle).
And also if you resize the browser the listing is not rendered as a vertical rectangle as it is supposed to.
My raw questions are:
1) How do I connect the image and the body text so there is no space inbetween?
2) How do I make the body text and image the same width when the body text needs to collapse underneath the photo? (When resizing browser or on device)
The HTML
<div class="five columns image">
<img src="Properties/9-Walter-Street-Claremont/Listing.jpg" alt="Listing">
</div>
<div class="ten columns body-info">
<h2>Walter Street <span>$2500/wk</span></h2>
<h3>Claremont, 6010</h3>
<p>Lorem Ipsum</p>
<div class="info">
<ul>
<li><img src="img/bedrooms.png"> 5</li>
<li><img src="img/bathrooms.png"> 3</li>
</ul>
</div>
</div>
The CSS
.body-info {
background-color: #fff;
height: 200px;
-webkit-box-shadow: 0px 1px 1px rgba(0,0,0,0.1);
-moz-box-shadow: 0px 1px 1px rgba(0,0,0,0.1);
box-shadow: 0px 1px 1px rgba(0,0,0,0.1);
margin-bottom: 30px;
padding: 0px;
}
.image a img:hover {
background-color: rgba(0,0,0,0.5);
background-image: url("img/eye.png");
background-position: center center;
background-repeat: no-repeat;
}
.body-info h2 a {
transition: color 0.2s ease-in;
-webkit-transition: color 0.2s ease-in;
color: #428f9c;
font-size: 23px;
font-weight: normal;
}
.image {
width: 270px;
float: left;
}
.body-info {
margin-left: 280px;
}
.body-info h2 a:hover {
color: #0b7587;
}
.body-info span {
margin-right: 15px;
color: #444;
}
.body-info p {
color: #777;
font-size: 16px;
}
.body-info ul {
list-style: none;
}
.body-info ul li {
color: #777;
}
Thank you in advance!
To help you a little bit on the way, you could use the #media on CSS.
With that you can change the style when for example the screen is smaller than a specific width.
HTML:
<div class="wrap">
<div class="image">img</div>
<div class="info">info</div>
</div>
CSS:
.wrap {
background: gray;
min-height: 200px;
padding: 10px;
}
.image {
width: 270px;
height: 180px;
background: lightgray;
display: inline-block;
}
.info {
background: lightsteelblue;
display: inline-block;
}
#media only screen and (max-width:600px){
.image, .info {
width: 100%;
display: block;
}
}
So what the style does is when you have a fullscreen it shows .image and .info next to each other (using display: inline-block;.
When the screen gets resized and smaller than 600px, for both the divs the display property will change to block, making them appear under each other.
JSFiddle DEMO
Referring to the example in your post, the only thing you need to do is to make or find a script that resizes your image when the screen gets smaller.
Hope this helps you.

Resources