Moving an image up in CSS - html

So, for the past hour I've being trying to move this image using the css property position. My problem is every time I move it using top or bottom it doesn't work correctly. Here's a screenshot of it before using said properties and after. Below you can find my html & css. Lastly, this position has to be absolute or the image completely disappears.
HTML
<section class="row posts">
<div class="col-md-6 col-md-offset-3">
<header><h3>What others have to say...</h3></header>
#foreach($posts as $post)
<article class="post" data-postid="{{ $post->id }}">
<p>{{ $post->body }}</p>
<div class="info">
Posted by {{ $post->user->user_name }} on {{ $post->created_at }}
</div>
<div class="interaction">
|
Dislike
#if(Auth::user() == $post->user)
|
Edit |
Delete
#endif
</div>
</article>
#endforeach
</div>
</section>
CSS
.heart{
background: url('http://localhost:8079/uncaughterror/public/src/img/web_heart_animation.png');
background-position: left;
background-repeat: no-repeat;
height: 50px; width: 50px;
cursor: pointer;
position: absolute;
left: 12px;
bottom: 5px; //This or 'top' is what causes my entire problem
background-size:1450px;
}
.heart:hover {
background-position: right;
}

How about adding this :
.interaction {
position: relative;
}

I think you should put the no-repeat at the same line as the background
It just work for me,i don't know why
https://jsfiddle.net/moongod101/2wh6b9rq/

Related

Why css backdrop-filter: blur() is working well except on active bootstrap-4 list-group-item?

I have gallery, inside gallery there is album-card component, and inside there is carousel.
When i added list-group and set one of items active it remains not blurred, and I don't understand why. Can anyone explain it to me?
this is gallery component html:
<div class="row">
<div class="col-3">
<div class="list-group">
<a
*ngFor="let album of galleryAlbums"
class="list-group-item list-group-item-secondary list-group-item-action
d-flex justify-content-between align-items-center"
routerLink="/gallery"
[queryParams]="{ selectedAlbumId: album.id }"
[class.active]="selectedAlbumId === album.id">
{{ album.name }}
<span class="badge badge-warning badge-pill">{{ album.photos.length}}</span>
</a>
</div>
</div>
<album-card class="col-9" *ngIf="selectedAlbum" [album]="selectedAlbum"></album-card>
</div>
carousel styles in .scss file:
.gallery-carousel {
display: flex;
justify-content: center;
align-items: center;
position: fixed;
top: 0;
left: 0;
height: 100vh;
width: 100vw;
background-color: rgba(100, 100, 100, 0.4);
backdrop-filter: blur(5px);
result:
I found that the problem was in an CSS property added by Bootstrap for the .active class:
.list-group-item.active {
z-index: 2;
}
So when I added z-index f.e. 5 to my .gallery-carousel it covered the problematic active list group item 😀

Div text and button does not center to middle of the page

I created a landing page like below:
I place the text and buttons in a div container and the alignment is correct but I am trying to move it below the logo so it looks naturally better. I tried using bottom to adjust the positioning but it does not reflect anything.
My code:
<body style="font-family:Verdana;color:#aaaaaa;">
<div class="backgroundImage logo">
<b>{{ __('SIGN UP AS A DEALER') }}</b>
<div class="container" >
<h1 > A home is made of <i>
<p >hopes</p></i> and <i><p >dreams</p> </i>
</h1>
<h1 >Let us<i> <p >inspire</p></i> you to build the perfect home!</h1> <br>
<a href="/login " class="btn grad1" ><b>{{ __('LOGIN') }}</b></a>
<b>{{ __('SIGN UP') }}</b>
</div>
</div>
</body>
SASS:
.backgroundImage {
background-image: url(/images/homepage.jpg);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
width: 100vw;
height: 100vh;
}
* {
box-sizing: border-box;
}
a.btn {
color: black;
border-radius: 10px;
background-color: #fbcc34;
}
h1 {
color: white;
}
.a {
top: 50%;
}
p {
display: inline;
font-size: 75px;
font-family: "Dancing Script" cursive;
font-family: "Tangerine", cursive;
}
text-align: center;
position: relative;
top: 50%;
// Add media query for mobile devices
#media (max-width: 767px) {
h1 {
font-size: 120%;
float: left;
}
p {
font-size: 170%;
}
.backgroundImage {
background-image: url(/images/homepage.jpg);
background-repeat: no-repeat;
background-position: center;
}
}
Can anyone point out why is it not positioning to the center?
Edit:
The positioning is now fixed but however when I switch to mobile layout, it goes like below:
How do I center the first sentence?
so you have to set position so bottom,left,right,top works!
.container {
position: relative;
text-align: center;
bottom: 30px;
}
Try that!
Try the margin-top property, for example: <div class="container" style="margin-top: 200px;">.
Do you want to move only button or along with that text too? If you want to move only button use this:
<div class="backgroundImage logo">
<b>{{ __('SIGN UP AS A DEALER') }}</b>
<div style="padding-top:40%"></div>
<div class="container" >
<h1 > A home is made of <i>
<p >hopes</p></i> and <i><p >dreams</p> </i>
</h1>
<h1 >Let us<i> <p >inspire</p></i> you to build the perfect home!</h1> <br>
<a href="/login " class="btn grad1" ><b>{{ __('LOGIN') }}</b></a>
<b>{{ __('SIGN UP') }}</b>
</div>
</div>
Or you want to bring only buttons just replace that div before the button.
And I'm not sure about here 40%, please give which will suit you. Many would say it's not a proper way to get the result but we can do as this too.

How to make an exception in my CSS

I'm quite new with HTML and CSS so this might be quite a rookie question, or I may have some messy code. Below is the HTML for a div of my webpage's front page;
<div id="header" class="hero container mainfrontimage">
<h3>WEBSITE TITLE </h3>
<img src="../images/Logo.png" id="headerimg">
<div class="buttons"><a class="btn btn-alt" href="../3 Join us/joinus.html">JOIN US</a> SHOP</div>
</div>
and the CSS..
#header {
background: url('../images/WEBSITE TITLE pics/placeholder2.jpg') no-repeat;
background-size: 100%;
border-top: 4px ridge #E0CC95;
border-bottom: 4px ridge #E0CC95;
opacity: 0.75;
}
Essentially the header ID fills the div with my background image exactly as I'd like it, with the right opaqueness and styles. But, because the title, logo and buttons in the HTML are all included in this, they also become less opaque. I was wondering if there's some way of making just the image opaque with the borders etc. and have the text not be affected- like an exception.
I've tried putting the title, logo and buttons into a separate div but because the image itself is in the CSS it means the original div with id="header" is empty.. which wouldn't make a lot of sense and doesn't work either.
Sorry if this is a huge mess, I'm really new to this. If anyone somehow figures out what I'm asking and can provide a solution I'd really appreciate it!
Don't apply background image directly to the div, if you want to control only the opacity background image, and not of the content. Instead, use a pseudo element like below.
<div id="header" class="hero container mainfrontimage">
<h3>WEBSITE TITLE </h3>
<img src="../images/Logo.png" id="headerimg">
<div class="buttons"><a class="btn btn-alt" href="../3 Join us/joinus.html">JOIN US</a> SHOP</div>
</div>
#header {
position: relative;
border-top: 4px ridge #E0CC95;
border-bottom: 4px ridge #E0CC95;
}
#header::after {
content: "";
background: url('../images/WEBSITE TITLE pics/placeholder2.jpg') no-repeat;
background-size: 100%;
opacity: 0.75;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
z-index: -1;
}

Place SVG in-line with html text headers

I'd like to put an SVG hyperlink to the left of these two page links:
The site uses Jekyll and is built off Poole. The site is nearly identical right now so any additional CSS details can be seen in Poole's repo
I'm struggling with how to place an image or svg in the masthead class below. I'd like the logo to be inline with page navigation. The img tag below currently displays nothing.
.masthead {
padding-top: 1rem;
padding-bottom: 1rem;
margin-bottom: 3rem;
}
.masthead-title {
margin-top: 0;
margin-bottom: 0;
color: $gray-4;
}
.masthead-title a {
color: inherit;
}
.masthead-title small {
font-size: 75%;
font-weight: 400;
opacity: .5;
}
<header class="masthead">
<h3 class="masthead-title">
{{ <img src="/assets/logo_small.svg" height="25" width="100"/> }} <!--site.title-->
{% for page in site.pages_list %}
<small>{{ page[0] }}</small>
{% endfor %}
</h3>
</header>
In the code you provided, it looks like the trouble is you put the image in a Liquid variable. It should be <img ...>, not {{ <img ... > }}
Here's a minimal snippet that removes everything not related to your question, showing the <img> inline with your links.
.masthead img {
width: 100px;
height: 25px;
}
<header class="masthead">
<h3>
<a href="">
<img src="/assets/logo_small.svg" />
</a>
<small>
link 1
</small>
<small>
link 2
</small>
</h3>
</header>

Transform widget with CSS :after background-image in a reusable component

I have a widget on my front page that I want to use many times but with another background image. I was trying to put another element that could reproduce the behavior from CSS :after but without success. Do you know the best approach for this?
HTML
<div class="widget-2 panel no-border bg-primary widget widget-loader-circle-lg no-margin">
<div class="panel-body">
<div class="pull-bottom bottom-left bottom-right padding-25">
<br>
<h3 class="text-white">My Title</h3>
<p class="text-white hint-text hidden-md">Lorem Ipsum</p>
</div>
</div>
</div>
CSS (less)
.widget-2 {
&:after {
background-image: url("#{assets-url}/img/social/person-cropped.jpg");
}
}
Result
Widget with backgroud-image
I would do it this way ... CSS only
HTML
<div class="widget-2...." style="background-image: url(...); ">
....
</div>
CSS
.widget-2 {
background-size: 0;
}
.widget-2:after {
background-image: inherit;
}
And of course one can have the resources as classes, if one feel that is more convenient than in markup
HTML
<div class="widget-2 img1 ....">
....
</div>
CSS
.img1 {
background-image: url(...);
}
.widget-2 {
background-size: 0;
}
.widget-2:after {
background-image: inherit;
}