Why does my CSS selector does not work as expected? - html

I am creating a gallery website my goal is the show option button on bottom of the picture when use hover over it.
Here is an example of what I want on pixabay
<div class="image-thumbnail col-lg-2 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="#">
<img class="img-responsive" src="http://placehold.it/400x300" alt="">
</a>
<div class="image-options">
<div class="btn-group" role="group">
<button type="button" class="btn btn-sm ">
<i class="fa fa-thumbs-up"></i>
</button>
<button type="button" class="btn btn-sm ">
<i class="fa fa-thumbs-down"></i>
</button>
<button type="button" class="btn btn-sm">
<i class="fa fa-facebook"></i>
</button>
<button type="button" class="btn btn-sm">
<i class="fa fa-google-plus"></i>
</button>
<button type="button" class="btn btn-sm">
<i class="fa fa-twitter"></i>
</button>
</div>
</div>
</div>
CSS
div.image-thumbnail div.image-options {
position: absolute;
z-index: 2000;
margin-top: -55px;
margin-left: 1px;
display: none;
}
div.image-thumbnail div.image-options:hover {
display: inline;
}
Any ideas ?
EDIT:
It turns out that
div.image-thumbnail div.image-options {
position: absolute;
z-index: 2000;
margin-top: -55px;
margin-left: 1px;
display: none;
}
Don't work at all as the image-options are still visible even with display:none

You can't hover element with display: none, it's not visible. Instead you should define :hover rule on .image-thumbnail element:
.image-thumbnail {
position: relative;
}
.image-thumbnail .image-options {
position: absolute;
z-index: 2000;
margin-top: -55px;
margin-left: 1px;
display: none;
}
.image-thumbnail:hover .image-options {
display: inline;
}

As stated in my comment.
div.image-thumbnail div.image-options:hover {
display: inline;
}
This is saying when we hover over div.image-options display it... This isn't possible. (As you have it set to display: none) plus this is not the element you want to set the hover on.
What you mean to say is
div.image-thumbnail:hover div.image-options {
display: inline;
}
When we hover over div.image-thumbnail then show div.image-options.

Related

Cant figure out how to make left and right block in footer

I need the left block to the left side of my footer and the right block to the right side of my footer. But for some reason both are underneath. Any help would be appreciated!
I tried a few things but didnt work and chatgpt wont give me the proper solution.
Below I inserted html and css, maybe someone could help me with this, would be nice.
.mastfoot .inner {
display: flex;
flex-wrap: wrap;
flex-direction: column;
}
.mastfoot .inner>div {
width: 25%;
}
.mastfoot .inner>div>a {
margin-right: 10px;
margin-bottom: 10px;
text-align: center;
}
.mastfoot .inner>div>a {
display: block;
}
.mastfoot .inner>div {
padding: 10px;
}
.d-flex {
display: flex;
flex-direction: column;
}
.btnfooter {
display: block;
margin-bottom: 5px;
}
.left-block {
justify-content: flex-start;
}
.right-block {
justify-content: flex-end;
}
<footer class="mastfoot mt-auto">
<div class="inner d-flex justify-content-between">
<div class="d-flex left-block">
<div>
<h4>Left Block</h4>
</div>
<div>
<a class="btn btnfooter btn-outline-danger btn-sm" href="#" target="_blank">.....</a>
<a class="btn btnfooter btn-outline-danger btn-sm" href="#" target="_blank">.....</a>
<a class="btn btnfooter btn-outline-danger btn-sm" href="#" target="_blank">.....</a>
<a class="btn btnfooter btn-outline-danger btn-sm" href="#" target="_blank">.....</a>
</div>
</div>
</div>
<div class="inner d-flex justify-content-between">
<div class="d-flex right-block">
<div>
<h4>Right Block</h4>
</div>
<div>
<a class="btn btnfooter btn-outline-warning btn-sm" href="#" target="_blank">.....</a>
<a class="btn btnfooter btn-outline-warning btn-sm" href="#" target="_blank">.....</a>
<a class="btn btnfooter btn-outline-warning btn-sm" href="#" target="_blank">.....</a>
</div>
</div>
</div>
</footer>

how to place button on top right corner of image

The image and buttons are inside a div. How can i make the image occupy the whole div with buttons on the top right corner on the image?
This is the div that contains two buttons and an image. How can i place the two buttons on the top right corner of the image?
I tried to do position:relative;top:25px but the button will behind the image
<div class="image">
<a href="{{ url('/image/'.$image->id.'/delete') }}">
<button type="button" class="btn btn-default delete-image-btn pull-right">
<span class="glyphicon glyphicon-trash"></span>
</button>
</a>
<a href="{{ url('/image/'.$image->id.'/edit') }}">
<button type="button" class="btn btn-default edit-image-btn pull-right">
<span class="glyphicon glyphicon-pencil"></span>
</button>
</a>
<img src="{{ $image->image }}" class="img img-responsive full-width">
</div>
Use relative and absolute like shown below to achieve the desired effect.
P.S: I have used T and P to denote the icons as they were not visible in the snippet.
.image {
position: relative;
display: inline-block;
}
.overlay {
position: absolute;
right: 0;
z-index: 5;
}
<div class="image">
<div class="overlay">
<a href="{{ url('/image/'.$image->id.'/delete') }}">
<button type="button" class="btn btn-default delete-image-btn pull-right">
T<span class="glyphicon glyphicon-trash"></span>
</button>
</a>
<a href="{{ url('/image/'.$image->id.'/edit') }}">
<button type="button" class="btn btn-default edit-image-btn pull-right">
P<span class="glyphicon glyphicon-pencil"></span>
</button>
</a>
</div>
<img src="https://picsum.photos/200" class="img img-responsive full-width">
</div>
Please try this code. Use Position relative and absolute like this:
.image {
position: relative;
}
.image .delete-image-btn,
.image .edit-image-btn {
position: absolute;
top: 0;
right: 0;
z-index: 1;
}
.image .edit-image-btn {
margin-right: 40px;
}
Though there are many ways, a simple solution would be to give the buttons a z-index property.
.delete-image {
z-index :1;
}
.image {
position: relative;
}
.image .actions {
right: 1em;
top: 1em;
display: block;
position: absolute;
}
.image .actions a {
display: inline-block;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="image">
<div class="actions">
<a href="{{ url('/image/'.$image->id.'/delete') }}">
<button type="button" class="btn btn-default delete-image-btn pull-right">
<span class="glyphicon glyphicon-trash"></span>
</button>
</a>
<a href="{{ url('/image/'.$image->id.'/edit') }}">
<button type="button" class="btn btn-default edit-image-btn pull-right">
<span class="glyphicon glyphicon-pencil"></span>
</button>
</a>
</div>
<img src="https://cdn.pixabay.com/photo/2013/07/12/17/47/test-pattern-152459_960_720.png" class="img img-responsive full-width">
</div>

How to create a fixed footer in HTML and CSS

I have created a fixed footer for my website:
HTML
<div class="card footerBF">
<div class="card-body space-around">
<button
type="button"
class="buttonBF"
routerLink="/myRouter"
>
<i class="fa fa-lock fa-lg"></i>
</button>
<button
type="button"
class="buttonBF"
routerLink="myRouter"
>
<i class="fa fa-globe fa-lg"></i>
</button>
<button type="button" class="buttonBF" routerLink="myRoute">
<i class="fa fa-plus fa-lg"></i>
</button>
<button
type="button"
class="buttonBF"
routerLink="myRouter"
>
<i class="fa fa-home fa-lg"></i>
</button>
</div>
</div>
CSS
.footerBF {
background-color: white;
text-align: center;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
font-size: 1em;
}
.buttonBF {
background-color: white;
color: grey;
display: inline-block;
border: none;
cursor: pointer;
}
The problem is that when I scroll, my footer moves, even though is supposed to be fixed. I attach one picture to show this effect:
There are Bootstrap UI elements for the a fixed bottom navbar, each with props to do this... check out Fixed bottom
<nav class="navbar fixed-bottom">
// Buttons
</nav>
However, if you want your current code from the question to work as intended. I'd just set the footer with display: flex, give it a height and justify-content and align-items center.
body {
background: black;
height: 2000px;
}
.footerBF {
background-color: white;
text-align: center;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
font-size: 1em;
height: 50px;
display: flex;
justify-content: center;
align-items: center;
border: 1px solid #f1f1f1;
}
button {
background-color: white;
border: none;
cursor: pointer;
}
<link href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" rel="stylesheet" />
<body>
<div class="card footerBF">
<div class="card-body">
<button type="button">
<i class="fa fa-lock fa-lg"></i>
</button>
<button type="button">
<i class="fa fa-globe fa-lg"></i>
</button>
<button type="button">
<i class="fa fa-plus fa-lg"></i>
</button>
<button type="button">
<i class="fa fa-home fa-lg"></i>
</button>
</div>
</div>
</body>

Display text in stack-mode next to an icon in a Flexbox

I have a comment icon that I want to display the number of comments and the word "Comments" next to it.
But the word "Comments" should be displayed under the number and not next to it.
Similar to this
So far the text is being displayed next to each other.
DEMO https://jsfiddle.net/halnex/d5sft5pt/9/
HTML
<div class="post-meta-alt">
<div class="social-share-top">
<span class="social-share-top-text">Share</span>
<a class="btn btn-social-icon btn-facebook">
<span class="fa fa-facebook"></span>
</a>
<a class="btn btn-social-icon btn-twitter">
<span class="fa fa-twitter"></span>
</a>
<a class="btn btn-social-icon btn-google">
<span class="fa fa-google"></span>
</a>
<a class="btn btn-social-icon btn-pinterest">
<span class="fa fa-pinterest"></span>
</a>
</div>
<div class="comments-top">
<a class="btn btn-social-icon btn-pinterest">
<span class="fa fa-comment"></span>
</a>
<p>78</p>
<p>Comments</p>
</div>
<div class="author-top">
author name
</div>
</div>
CSS
.post-meta-alt {
border-top: 1px solid #e0e0e0;
border-bottom: 1px solid #e0e0e0;
padding: 20px 0;
margin-top: 20px;
margin-bottom: 20px;
display: flex;
}
.post-meta-alt span.social-share-top-text {
text-transform: uppercase;
margin-right: 10px;
}
.post-meta-alt .comments-top,
.post-meta-alt .author-top {
display: inline-flex;
margin-left: 20px;
}
PS: Is this the correct way of doing it with Bootstrap? Using Flexbox or is there a better conventional way of achieving this?
You need to wrap the paragraphs in a div:
<div class="coment">
<p>78</p>
<p>Comments</p>
</div>
And add style to organize them
.coment p {
margin: 3px;
line-height: 1;
}
See jsfiddle

Ionic: Place text under Icon

I want to create Buttons with icons and text under it. I started with the following:
<ion-view view-title="Title">
<ion-content>
<div class="list">
<a ng-repeat="image in images" class="item">
<div class="container">
<img ng-src="{{image}}" />
</div>
<div class="container-side-menu">
<div>
<button class="button button-icon">
<i class="icon ion-eye"></i> preview
</button>
</div>
<div>
<button class="button button-icon">
<i class="icon ion-crop"></i> crop
</button>
</div>
<div>
<button class="button button-icon">
<i class="icon ion-android-options"></i> styles
</button>
</div>
<div>
<button class="button button-clear">
<i class="icon ion-social-tumblr"></i> text
</button>
</div>
</div>
</a>
</div>
</ion-content>
</ion-view>
with the following css:
.container {
margin-left: auto;
margin-right: auto;
background-position: center center;
background-image: url("../img/frames/frame_01.png");
background-size: contain;
background-repeat: no-repeat;
width: 245px;
height: 325px;
position: relative;
}
.container img {
width: 87.5%;
height: 68.5%;
position: absolute;
top: 0;
bottom: 13%;
left: 0;
right: 0;
margin: auto;
}
.container-side-menu {
width: 10%;
height: 50%;
top: 20%;
right: 15px;
position: absolute;
margin: auto;
}
.container-side-menu .button {
color: white !important;
}
but the result of it is ofcourse that the text is written next to the icons of the buttons.
How can i set the text directly under the buttons without padding and how can i make my icons greater and my text smaller?
I was able to get the text under the icons:
<ion-view view-title="Title">
<ion-content>
<div class="list">
<a ng-repeat="image in images" class="item">
<div class="container">
<img ng-src="{{image}}" />
</div>
<div class="container-side-menu">
<div>
<button class="button button-icon">
<i class="icon ion-eye"></i>
<span>preview</span>
</button>
</div>
<div>
<button class="button button-icon">
<i class="icon ion-crop"></i>
<span>crop</span>
</button>
</div>
<div>
<button class="button button-icon">
<i class="icon ion-android-options"></i>
<span>styles</span>
</button>
</div>
<div>
<button class="button button-icon">
<i class="icon ion-social-tumblr"></i>
<span>text</span>
</button>
</div>
</div>
</a>
</div>
</ion-content>
</ion-view>
css:
.container-side-menu div {
vertical-align: top;
text-align: center;
}
.container-side-menu span {
display: block;
font-size: 10px;
}
BUT: between the icon and the text is too much space. how can i remove that space?
Alter the line-height of the button inside the container.
angular.module('app', ['ionic']);
.container-side-menu {
width: 10%;
top: 15%;
right: 15px;
position: absolute;
margin: auto;
}
.container-side-menu .button {
font-size: 10px;
line-height: 10px; // Add
}
.container-side-menu .button-icon .icon {
display: block;
font-size: 30px;
margin-bottom: 3px !important;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<link href="http://code.ionicframework.com/1.0.0/css/ionic.min.css" rel="stylesheet">
<script src="http://code.ionicframework.com/1.0.0/js/ionic.bundle.js"></script>
</head>
<body ng-app="app">
<ion-pane>
<ion-header-bar class="bar-stable">
<h1 class="title">Awesome App</h1>
</ion-header-bar>
<ion-content class="padding">
<div class="container-side-menu">
<div>
<button class="button button-icon">
<i class="icon ion-eye"></i> preview
</button>
</div>
<div>
<button class="button button-icon">
<i class="icon ion-crop"></i> crop
</button>
</div>
<div>
<button class="button button-icon">
<i class="icon ion-android-options"></i> styles
</button>
</div>
<div>
<button class="button button-icon">
<i class="icon ion-social-tumblr"></i> text
</button>
</div>
</div>
</ion-content>
</ion-pane>
</body>
</html>
Using this css bellow:
.button-icon .icon {
display: block; /*** icons on the texts ***/
font-size: 36px; /*** increase size of icons ***/
margin-bottom: 3px;
}