CSS top right icon - css

I have a loop that shows all the users comments. I'm trying to add a trash icon on the top-right of each comment, but it's putting all the icons at the same place in one div. I don't want the icon to change the position of the comments and that's why I did position absolute, but it's not working.
Loop code:
<div class="col-md-5 all">
<div class="col-md-12 hello">
#foreach($comment as $comments)
#if($comments->image_id == $image->id)
<div id="{{$comments->id}}" class="ajaxrules">
<div class="col-md-2">
<img src="{{$comments->user_avatar}}" class="img-circle buddy">
</div>
<div class="col-md-10">
<h4>{!! $image->user_name !!}</h4>
<p class="left">{!!$comments->body!!} </p>
</div>
<div class="deletecomment">
<i class="fa fa-trash-o"></i>
</div>
</div>
#endif
#endforeach
<div class="addavatar">
</div>
</div>
</div>
css:
.deletecomment{
display: block;
position: absolute;
top: 0;
right: 0;
clear:both;
}
.addavatar, .ajaxrules{
padding-right: 60px;
padding-top: 10px;
}

You need to add position: relative
to .ajaxrules
So the trash icon will be absolute to it's parent
Edit: adding additional information on position absolute/relative
https://css-tricks.com/absolute-positioning-inside-relative-positioning/

Related

Place Font-Awesome-5 Icon as Bootstrap-4 Card background

I want to use a Font Awesome 5 icon as card background image using Bootstrap-4!
I tried everything what I found from the internet but nothing worked.
I'm using Angular2 (v8) along with Bootstrap 4.
The following code worked for me. I've simplified what I use but you still get a font-awesome icon as background and you can put text on top of it:
HTML:
<div class="container-fluid">
<div class="row">
<div class="col-md-4 col-sm-6 d-flex">
<div class="class-box">
<div class="bg-primary">
<i class="fa fa-question big-centered-icon"></i>
</div>
<div class="box-content">
<h3 class="title-bg text-outline"><Strong>TITLE</Strong></h3>
<h4 class="title-bg text-outline">Subtitle</h4>
<h4 class="title-bg text-outline"><Strong> Subtitle</Strong></h4>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 d-flex">
<div class="class-box">
<div class="bg-primary">
<i class="fa fa-question big-centered-icon"></i>
</div>
<div class="box-content">
<h3 class="title-bg text-outline"><Strong>HELLO</Strong></h3>
<h3 class="title-bg text-outline"><Strong> 2nd HELLO</Strong></h3>
<h3 class="title-bg text-outline"><Strong> 3rd HELLO</Strong></h3>
</div>
</div>
</div>
</div>
</div>
CSS:
.big-centered-icon {
font-size: 144px;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
display: flex; /* add */
justify-content: center; /* add to align horizontal */
align-items: center; /* add to align vertical */
}
.class-box{ text-align:center;position:relative;margin:8px;width: 100%;padding-bottom: 75%}
div.class-box > div { position:absolute;top:0;bottom:0;left:0;right:0;overflow:hidden;padding-top:15%}
.class-box .title-bg{font-size:24px;color:#000;}
See the working fiddle.

Link doesn't stay on the top of the screen with the image

I have a website. And a logo which is always on the top of the screen. When you scroll down is still there, the top of the screen, you still see it. This is fine. On the top the logo image have a link, but when you scroll down, you lose it. I want the link to go with the image. I hope i was clear.
Here is the html:
<div class="col-md-12" id="menu">
<div class="col-xs-3 col-sm-2 col-md-2" id="logoparent">
<div id="logo">
<!--<h3>LOGO</h3>-->
<img src="Logo.png" id="thelogo">
</div>
</div>
<div class="col-xs-1 col-sm-2 col-md-6 space">
<!-- empty -->
</div>
<div class="col-xs-8 col-sm-2 col-md-1 menuitem" id="home">
<h3>Home</h3>
</div>
<div class="col-xs-12 col-sm-2 col-md-1 menuitem" id="gallery">
<h3>Gallery</h3>
</div>
<div class="col-xs-12 col-sm-2 col-md-1 menuitem" id="about">
<h3>About</h3>
</div>
<div class="col-xs-12 col-sm-2 col-md-1 menuitem" id="contact">
<h3>Contact</h3>
</div>
</div>
And the css:
#logo{
position: fixed;
z-index: 99;
height: 60px;
width: auto;
overflow: hidden;
margin-left: auto !important;
margin-right: auto !important;
}
#logoa{
position: relative;
z-index: 99;
}
#thelogo{
position: fixed;
z-index: 99;
height: 50px;
width: auto;
margin-top: 5px;
}
#menu{
position: relative;
z-index: 5;
}
#content-all{
position: relative;
z-index: 5; /*which is everything under the menu*/
}
I would suggest you to add a link to that logo by itself so when you click to the logo you go to the appropriate link, always if that logo has something to do with the link, otherwise add use nested DOM to style it.
You can put all menu tags in main tag and set css style for main tag like this
#menu1{
position: fixed;
top:10px;
left:10px;
height: 60px;
width:50px;
}
Check this
JSFiddle

How to create sticky bottom search box Bootstrap (React)

I have been trying for hours trying different examples I have found, and none seem to work.
What I want to do (without the custom JS): http://jsfiddle.net/paulalexandru/Z2Lu5/
However, I can't get it to work within Bootstrap. I am specifically using React-Bootstrap (I have changed the below code to normal HTML for those unfamiliar with React/React-Bootstrap), but I don't believe that to be the problem. I have a setup along the lines of:
<body>
<div class="container-fluid main">
<div class="row">
<div class="col-md-2 sidebar"
<my sidebar elements>
</div>
<div class="col-md-10">
<some random empty div (that will fill in the future)>
<div class="search">
<div className="panel-group">
<div className="panel panel-default">
<div className="panel-heading">
<a data-toggle="collapse" data-parent="#accordion" href="#searchResultsContainer">
<input type="text" onchange="handleChange()" />
</a>
</div>
<div id="searchResultsContainer" className="panel-collapse collpase">
<div className="panel-body">
<my table containing search results from the server>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
However, no matter how hard I try
.search {
position: fixed;
bottom: 0;
width: 100%;
}
You will also notice stuff to try and make the search results accordion, but that's useless to me until I can get this box to stay at the bottom.
My guess is that the Rows/Columns of Bootstrap are causing some issues. I can't move the search box out of the grid and to the bottom (which does work) because it then also covers the sidebar, and I am using the grid system to keep the search box dynamically sized/placed.
Also, I tried this but it didn't seem to work: Making expandable fixed footer in Bootstrap 3?
The solution is position: fixed (you can see the other example using it as well). It should work no matter what framework you are using.
body
{
margin: 0;
padding: 0;
}
.search
{
background: rgba(255,0,0,0.5);
bottom: 0;
position: fixed;
width: 100%;
}
#media only screen and (min-width: 550px)
{
.search
{
left: 50%;
margin-left: -250px;
width: 500px;
}
}
#media only screen and (min-width: 850px)
{
.search
{
margin-left: -400px;
width: 800px
}
}
<div class="container-fluid main">
<div class="row">
<div class="col-md-2 sidebar">
<div>my sidebar elements</div>
</div>
<div class="col-md-10">
<div>some random empty div (that will fill in the future)</div>
<div class="search">
<div className="panel-group">
<div className="panel panel-default">
<div className="panel-heading">
<a data-toggle="collapse" data-parent="#accordion" href="#searchResultsContainer">
<input type="text" onchange="handleChange()" />
</a>
</div>
<div id="searchResultsContainer" className="panel-collapse collpase">
<div className="panel-body">
<div>my table containing search results from the server</div> </div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
JSFiddle

the <a> tag in my carousel is showing dead link in bootstrap

the anchor tag in my carousel is showing dead link. i.e. cannot hover over it. everything else works fine. but the link is not working inside the div. i have used all the files from bootstrap and have not made any changes to the scripts.
HTML:
<div class="carousel-inner">
<div class="item active">
<div class="fill" style="background-image:url('images/slide1.jpg'); background-size:cover;"></div>
<div class="carousel-caption">
<h1>Caption 1</h1>
<p></p>
Read More ยป
<br/>
<div class="tech">
<img src="images/tech.png" />
</div>
</div>
</div>
<div class="item">
<div class="fill" style="background-image:url('images/slide2.jpg'); background-size:cover;"></div>
<div class="carousel-caption">
<h1>Caption 2</h1>
<p></p>
</div>
</div>
<div class="item">
<div class="fill" style="background-image:url('images/slide3.jpg'); background-size:cover;"></div>
<div class="carousel-caption">
<h1>Caption 3</h1>
</div>
</div>
</div>
In the comments provided to patel.milanb's answer, the author points to a live example of his problem: http://itechnepal.com/new_site//
The issue: The <ol> containing the carousel indicators overlaps a link, which therefor is not clickable.
Removing bottom: 10px; from .carousel-indicators will solve the issue.
CSS:
.carousel-indicators {
position: absolute;
/*bottom: 10px; <- remove this*/
left: 50%;
z-index: 15;
width: 60%;
padding-left: 0;
margin-left: -30%;
text-align: center;
list-style: none;
}
As what i could understand from your question.
link is not working inside DIV
I would say you did not provided any link to your <a> tag
<a href="#" class="read">
replace with:
<a href="http://www.google.com/" class="read">
Update: remove your style from css
.carousel-indicators {
top: 180px;
}
look into bootstrap.css line no: 6590
OR remove bottom: 10px; from class .carousel-indicators Line no: 6523

Align two buttons at the bottom of the page

I have to align two buttons at the bottom of the page, but I can not do it. One is the button "gallery" and the other is icon linkedin.
<div class="container fill">
<div id="myCarousel" class="carousel slide">
<div class="carousel-inner">
<div class="item">
<div class="fill" style="background-image:url('http://www.mysite/images/category/image.jpg');background-position: center;">
<div class="container">
<div class="carousel-caption">
<h1>TITLE</h1>
<p class="lead">Description</p>
</div>
</div>
<div class="pull-right">
<a class="btn btn-large btn-primary" href="categories.php?id=17">View Gallery</a>
</div>
</div>
</div>
</div>
<div class="pull-left">
<div class="social-caption">
<button class="btn btn-large btn-linkedin">
<i class="icon-linkedin"></i><span><a style="color:white" vhref="http://www.linkedin.com/"> | Linkedin</span></button>
</div>
css for the two buttons:
.social-caption {
background-color: transparent;
position: relative;
max-width: 100%;
padding: 0 20px;
bottom: 45px;
left: 5px;
}
.gallery-button {
background-color: transparent;
position: relative;
max-width: 100%;
padding: 0 20px;
bottom: 45px;
right: 5px;
}
The two buttons do not appear aligned. This problem is seen especially with mobile devices
Solutions? Thanks
You could do something like THIS, for example. It uses position:absolute to locate the buttons at the bottom of the page's content (bottom:0) - or relative to their parents positioning (in this case the body. The alternative would be to use position:fixed which would ensure the buttons appear at the bottom of the viewport at all times.
See the difference between absolute positioning and fixed positioning.
HTML
<button>Button 1</button>
<button>Button 2</button>
CSS
body{
position:relative;
}
button{
position:absolute;
bottom:0;
}
button:last-child{
left:100px;
}
May be you could use this:
<input type='button' style='position:fixed; top:94%; left:82%; width:100px' value='
this means the button will appear at the right corner in the bottom of your page.
//hope so this code helps you.
.center{
justify-content: center;
display:flex;
align-item: center
}
.right{
justify-content: flex-end;
display:flex;
}
//for center align
<div class="center">
<button>First Button</button>
<button>Second Button</button>
</div>
//for right align
<div class="right">
<button>First Button</button>
<button>Second Button</button>
</div>

Resources