To make whole div clickable? - html

I have a template of handlebars in which there are multiple div which i need to make clickable.
However, in my div the text is dynamic, how will i be able to make whole div clickable. Here is the code
<div class="row">
{{#each event}} {{#is this.event ../eventName }}
<div class="col s12 m3 13 al">
<div class="card ">
<div class="card-image">
<img src="/Small/{{this.imageId}}.JPG">
<span class="imageClick"></span>
</div>
<div class="card-action sp1">
<div class="action-time">
<a href="/{{this.imageId}}/love" class="like sp">
<i class="material-icons fav">favorite</i>
</a>
<span id="{{this.imageId}}" class="like-text">{{this.love}}</span>
</div>
<div class="action-time">
<a href="/{{this.imageId}}/laugh" class="haha sp">
<i class="material-icons laugh">sentiment_very_satisfied</i>
</a>
<span id="{{this.imageId}}laugh" class="haha-text">{{this.laugh}}</span>
</div>
<div class="action-time">
<a href="/{{this.imageId}}/sad" class="downvote sp">
<i class="material-icons down">trending_down</i>
</a>
<span id="{{this.imageId}}sad" class="downvote-text">{{this.sad}}</span>
</div>
{{!-- {{this.imageId}} --}}
</div>
<div class="card-action">
<a class="waves-effect waves-light btn share">button</a>
</div>
</div>
</div>
{{/is}} {{/each}}
I want to make my div action-time clickable with the link in the a tag. I tried to use the popular <span> solution like this but no use. It works for the last action-time making first two not working. How can i solve this.
Css code for action-time and card is:
.action-time{
display: inline-block;
border: 1px solid rgba(202, 202, 202, 0.733);
width: 32%;
padding-top:2px;
padding-left: 4px;
border-radius:8px;
}
and for card :
.card {
margin: 10px;
padding: 5px;
border-radius: 8px;
box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
}
.card-action {
padding: 5px 0px !important;
/* padding-right: 5px !important; */
}
Here is what my webpage looks like, I have multiple of those cards
I want to make the whole area in border of heart clickable, rather than just the image to heart.

You can update your html so that the <span> is inside your <a>.
<a href="/{{this.imageId}}/laugh" class="haha sp">
<i class="material-icons laugh">sentiment_very_satisfied</i>
<span id="{{this.imageId}}laugh" class="haha-text">{{this.laugh}}</span>
</a>
Displaying your <a> as a block element will have it fill up the entire <div>. Then you can float your <span> to the right and style it accordingly until it's where you want it exactly.
.action-time a {
display: block;
}
.action-time span {
float: right;
}

You can write some javascript to handle the operation
$(" .action-time").click(function() {
window.location = $(this).find("a").attr("href");
return false;
});
Looks for a link inside div with class of "action-time". Redirects to that links value when anywhere in div is clicked.

Related

Why Won't The Float Right Class Move My Icon to Far Right Of Border Box

I have a border box which I am trying to a icon to the far right of the border box using bootstrap 4.3 class float-right but the icon does not move and I can't understand why. I have a child component in which the scss is associated with. I have tried a combination of things but it still does not work. Can someone explain to me what the issue is. Code snippet includes.
Cartitem.html
<div class="container-md" style="height:50%; width:150px;">
<img class="img-fluid" [src]="cartItem.imageUrl" alt="Cart Item">
<div class="text-nowrap" style="font-size:13px; width: 400px">{{cartItem.productName}}
</div>
<div style="font-size:13px"><strong>{{ (cartItem.price) | currency}}</strong></div>
<div class="float-right" style=" clear:both">
<span ><i class="fa-solid fa-trash-can" style="color:#D30169;cursor: pointer;
">
</i></span>
</div>
</div>
cart.html
<div class="container" style="margin-bottom:20px">
<h1 style="text-align: center">Shopping Cart</h1>
<div class="cart-borderBox">
<div class="inside-bB">
div *ngFor="let item of cartItems; let i = index">
<app-cart-item [cartItem]="item"></app-cart-item>
</div>
</div>
</div>
</div>
scss
.cart-borderBox{
box-sizing: border-box;
margin: 0 auto;
/*height: auto;*/
width: 70%;
}
.inside-bB{
border: 3px solid $primary-color;
padding: 50px;
margin:0 auto;
border-radius: 8px;
}

How can i make my footer responsive and text on it horizontally align?

I am working on a project and i can't seem to find a way that works to center and make my footer responsive.
This is my html code.
#footer {
position: absolute;
left:0;
bottom: 0;
width: 100%;
height: 2.5rem;
background-color: black;
border-top: 4px solid #F2D380 !important;
}
.socialIcon {//update
width: 20px;
}
<div id="footer">
<div class="col-lg-2 link_list">
Company Information
</div>
<div class="col-lg-2 link_list">
<a href="#" > Privacy Policy and User Agreement </a>
</div>
<div class="col-lg-2 link_list">
About
</div>
<div class="col-lg-2 link_list">
<a href="#" >
©2019 Copyright claim
</a>
</div>
```
<div class="col-sm-6 col-lg-3">//update
<a href="#">
<img src="images/linkedin.png" class=" socialIcon">
</a>
<a href="#" >
<img src="images/instagram.png" class=" socialIcon">
</a>
<a href="#">
<img src="images/facebook.png" class=" socialIcon">
</a>
<a href="#" >
<img src="images/youtube.png" class="socialIcon">
</a>
</div>
</div>
```
I tried some bootstrap classes like justify-content-center but it simply does not work. I know i need to be looking at flexbox but it won't work and i don't know what the problem is.
Thank you in advance for answering.
*Update after i did what i saw in the comments it doesn't work with the socialmedia icons.
I've edited your codes. I explained what I changed in the comment lines. I removed the display table. You don't need this with this codes.
Html :
<div id="footer">
<div class="row text-center"> // I added row here, and I've got all the columns in a row, because all columns must be in a row. I added a "text center" class to keep all the text in the middle.
<div class="col-sm-6 pb-sm-2 col-lg-3"> // that's how I arranged your columns . So they will adjust their width for each width value
Company Information
</div>
<div class="col-sm-6 col-lg-3">
Privacy Policy and User Agreement
</div>
<div class="col-sm-6 pb-sm-2 col-lg-3"> // "pb-sm-2" class to add padding bottom when dimensions are sm
About
</div>
<div class="col-sm-6 col-lg-3">
<a href="#">
©2019 Copyright claim
</a>
</div>
</div>
</div>
Css:
#footer {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
/* height: 2.5rem; */ you can use padding this way instead of specifying height. if you give a single height value, you will need to set height separately for all dimensions.
padding: 20px;
background-color: black;
border-top: 4px solid #F2D380 !important;
}
I hope I could help. Good Luck!
See the code below. You can forget about wrapping each anchor within a "div". It will be a lot easier to simply group them into the parent DIV and then target them. This should work and you can have more flexibility. Also, don't have to worry about flexbox or any external libraries.
<style>
body{
height:2000px; /* for demonstration purposes*/
}
/* position the footer div RELATIVE and give it a "top" property of 100% so it always sits at the bottom regardless of your window height*/
#footer {
position: relative;
top:100%;
width: 100%;
height: 2.5rem;
background-color: black;
border-top: 4px solid #F2D380 !important;
}
/* center all items INSIDE the link_list DIV*/
.link_list{
text-align:center;
}
/* target all the ANCHOR tags as inline elements*/
.link_list a {
margin:50% 20px;
color:white;
text-decoration:none;
text-align: center;
flex: 0 0 16.666667%;
}
</style>
<body>
<div id="footer">
<div class="col-lg-2 link_list">
Company Information
<a href="#" > Privacy Policy and User Agreement </a>
About
<a href="#" >©2019 Copyright claim</a>
</div>
</div>
</body>
Add display:flex; to #footer and it gets a bit of responsiveness.
quick fiddle => https://jsfiddle.net/0b9hoag1/

Button and Text distance too far

I have 4 button and text arrange in each column. ( see picture bellow)
My problem is text title of button is too far from icon.
my css:
.ButtonPDetails {
font-size:10px !important;
overflow: hidden;
white-space: nowrap;
}
.col{
text-align:center !important;
}
.rowL{
padding-bottom:0px !important;
margin:0px !important;
}
.my-icon:before,
.my-icon{
font-size:20px !important;
display:block !important;
line-height: 40px !important;
}
Here my html:
<div class="row rowL">
<div class="col">
<a href="" class="button button-icon ButtonPDetails">
<i class="icon ion-bag my-icon" style="padding: 0px;margin: 0px"></i>
{{$root.themeConfig.lblPlaceOrder}}
</a>
</div>
<div class="col">
<a href="" class="button button-icon ButtonPDetails">
<i class="icon ion-ios-cart my-icon" style="padding: 0px;margin: 0px"></i>
{{$root.themeConfig.lblAddToCart}}
</a>
</div>
<div class="col">
<a href="" class="button button-icon ButtonPDetails">
<i class="icon ion-ios-information-outline my-icon" style="padding: 0px;margin: 0px"></i>
{{$root.themeConfig.lblInfo}}
</a>
</div>
<div class="col">
<a href="" class="button button-icon ButtonPDetails">
<i class="icon ion-android-globe my-icon" style="padding: 0px;margin: 0px"></i>
{{$root.themeConfig.lblShare}}
</a>
</div>
</div>
i want distance between button and text about 5px.
please help me solve this.
If you don't have access to the generated HTML/CSS that renders the content inside the {{ }} tags, which is the real culprit, then you may be able to work around it by modifying your CSS for my-icon
.my-icon {
font-size:20px !important;
display:block !important;
line-height: 40px !important;
padding: 0px !important;
margin: 0px 0px -20px !important; /* top, right/left, bottom */
}
And remove the CSS inline in the HTML.
The -20px bottom margin may compensate for the padding added by the generated HTML.

HTML Vertical Line with Buttons in The Middle

I am trying to set a vertical line with buttons in the middle with bootstrap.
Using Bootstrap simple vertical line:
<div class="row">
<div class="col-md-6" style="padding-right:20px; border-right: 1px solid #ccc; " >
Area 1
</div>
<div>
Area 2
</div>
</div>
Above only shows a vertical line, but I wanted to be able to add these right in the middle of that vertical line.
<span class="glyphicon glyphicon-arrow-left"></span>
<span class="glyphicon glyphicon-arrow-right"></span>
I couldn't really figure out how to position it using CSS. Is there a good way to go about this?
Any suggestions?
Edit:
I added -
<div class="round" style="position: absolute; top: 40%; right: -13px;">
<span class="glyphicon glyphicon-chevron-right" style="font-size: 1.2em; cursor: pointer;"></span>
</div>
<div class="round" style="position: absolute; top: 55%; right: -14px;">
<span class="glyphicon glyphicon-chevron-left" style="font-size: 1.2em; cursor: pointer;"></span>
</div>
It works, but the vertical line is in between the buttons.. Any suggestions on updating this?
Try this something like this
<div class="row">
<div class="col-md-6">
<div style="padding-right:20px; border-right: 1px solid #ccc; " >Area 1</div>
</div>
<div>
Area 2
</div>
You could use the after selector in css: http://www.w3schools.com/cssref/sel_after.asp
Using it you could do something like:
<div class="row">
<div class="col-md-6 myStyle" style="" >
Area 1
</div>
<div>
Area 2
</div>
</div>
.myStyle {
padding-right:20px; border-right: 1px solid #ccc; }
.myStyle::after{
font-family: 'Glyphicons Halflings';
content: "whatever the icon you want is";
}
You can then use CSS to position the icons however you want.
If you'd like to use more than one Icon you could use the :before selector on the button on the right, and the after on the button on the left.

zurb foundation 5 icon bar Text Misaligned

I have a weird issue with the text under the icon bar not being centered under the icons.
code example
<div class="row">
<div class="small-12 columns">
<div class="icon-bar five-up small">
<a class="item" a href="/index.html">
<i class="fi-home"></i>
<div>
<label>Home</label>
</div>
</a>
<a class="item" a href="/cart.html">
<i class="fi-shopping-cart"></i>
<div>
<label>Cart</label>
</div>
</a>
<a class="item" a href="/pages/about-us">
<i class="fi-info"></i>
<div>
<label>About</label>
</div>
</a>
<a class="item" a href="/pages/contact-us">
<i class="fi-mail"></i>
<div>
<label>Contact</label>
</div>
</a>
<a class="item" a href="/account/login">
<i class="fi-torso"></i>
<div>
<label>Account</label>
</div>
</a>
</div>
</div>
</div>
I've tried to center the labels with no luck. Has anyone had any issue with this before. Can't post a screenshot since it's a new account. but the contact label and account label seem to start on the left of the icon and go right instead of the start of the actual icon box.
Ok your problems is about CSS in foundation. the property "padding" here:
.icon-bar > * {
font-size: 1rem;
padding: 1.25rem;
}
To fix that, you need to add a media query for mobile. Maybe something like:
#media (max-width: 400px) {
a.item {
padding-left: 0;
padding-right: 0;
position: relative;
text-align: center;
}
}
Change the value 400px of your resolution. If its doesn't work because CSS style is overrite by another.. change padding-left and padding-right for:
padding-left: 0 !important;
padding-right: 0 !important;
Check this JSFiddle