I am using angular ng-repeat to get several divs. The code in original template html is :
<div class="span5 noMarginLeft">
<div class="dark">
<h1>Timeline</h1>
<div class="timeline">
<div class="timeslot">
<div class="task">
<span>
<span class="type">appointment</span>
<span class="details">
Dennis Ji at Bootstrap Metro Dashboard HQ
</span>
<span>
remaining time
<span class="remaining">
3h 38m 15s
</span>
</span>
</span>
<div class="arrow"></div>
</div>
<div class="icon">
<i class="icon-map-marker"></i>
</div>
<div class="time">
3:43 PM
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
and the style of each div (class: 'timeslot' or 'timeslot alt') is auto-calculated for its height:
and the result of the code is:
when I use ng-repeat to get these divs, (code here)
<div class="timeslot" ng-repeat="comment in allComments">
<div class="task">
<span>
<span class="type">{{comment.userId}}}</span>
<span class="details">
{{comment.content}}
</span>
<span>
<span class="remaining">
{{comment.dislike}}
</span>
</span>
</span>
<div class="arrow"></div>
</div>
<div class="icon">
<i class="icon-map-marker"></i>
</div>
<div class="time">
3:43 PM
</div>
</div>
the style of the div is gone, and the height of each div is not auto-calculated. How can I solve this? Thanks in advance.
You should create a directive to make the calculation. if you are doing this with jquery then you are going to face same issue.
/**
* Lets create directive
*/
angular
.module('demoApplication')
.directive('autoHeight', [function () {
return {
restrict: 'A',
link: function (scope, element, attrs) {
//Do your calculations here
console.log(element.css('height'));
}
};
}]);
HTML
<div class="timeslot" ng-repeat="comment in allComments" auto-height>
<div class="task">
<span>
<span class="type">{{comment.userId}}}</span>
<span class="details">
{{comment.content}}
</span>
<span>
<span class="remaining">
{{comment.dislike}}
</span>
</span>
</span>
<div class="arrow"></div>
</div>
<div class="icon">
<i class="icon-map-marker"></i>
</div>
<div class="time">
3:43 PM
</div>
</div>
Woring plunker for directive
Related
Problem: Divs not aligned:
The problem is when the text wraps, for example Money back guarantee, pushes the div out of alignment with 30 days.
I am trying to use the grid approach to first define two columns.
My code:
.inline-features {
display: grid;
grid-template-columns: repeat(2, 1fr);
}
<div class="inline-features">
<div class="feature">
<div class="price col-1-item">
<span>
Price
</span>
</div>
<div class="money-back col-1-item">
<span>
Money back guarantee
</span>
</div>
<div class="number-of-lessons col-1-item">
<span>
Number of lessons
</span>
</div>
<div class="number-of-users col-1-item">
<span>
Number of users
</span>
</div>
<div class="country col-1-item">
<span>
Based in country
</span>
</div>
<div class="support col-1-item">
<span>
Support
</span>
</div>
<div class="video-lessons col-1-item">
<span>
Video lessons
</span>
</div>
<div class="downloadable-files col-1-item">
<span>Downloadable files</span>
</div>
</div>
<div class="feature-item">
<div class="price-item col-2-item">
<span> From xx to xx </span>
</div>
<div class="money-back-item col-2-item">
<span> 30 days </span>
</div>
<div class="number-of-lessons-item col-2-item">
<span> 300+ </span>
</div>
<div class="number-of-users-item col-2-item">
<span> 35k + </span>
</div>
<div class="country-item col-2-item">
<span> UK</span>
</div>
<div class="support-item col-2-item">
<span> 24/7 live chat support </span>
</div>
<div class="video-lessons-item col-2-item">
<span> Yes </span>
</div>
<div class="downloadable-files-item col-2-item">
<span> Yes </span>
</div>
</div>
</div>
Your HTML structure is not correct. Try this way.
To do this type of design, you can use table. This will be better way for manage.
.inline-features{
width: 250px;
}
.row {
display: grid;
grid-template-columns: repeat(2, 1fr);
}
.col-1-item,
.col-2-item {
border: 1px solid black;
}
<div class="inline-features">
<div class="row">
<div class="col-1-item">
<span> Price </span>
</div>
<div class="col-2-item">
<span> From xx to xx </span>
</div>
</div>
<div class="row">
<div class="col-1-item">
<span> Money back guarantee </span>
</div>
<div class="col-2-item">
<span> 30 days </span>
</div>
</div>
<div class="row">
<div class="col-1-item">
<span> Number of lessons </span>
</div>
<div class="col-2-item">
<span> 300+ </span>
</div>
</div>
</div>
.inline-features {
display: grid;
grid-template-columns: repeat(2, 1fr);
font-size: 4rem;
border: 1px solid gray;
}
.col-1-item,
.col-2-item {
padding: 1rem;
height:140px;
border: 1px solid gray;
}
<div class="inline-features">
<div class="feature">
<div class="price col-1-item">
<span>Price</span>
</div>
<div class="money-back col-1-item">
<span>Money back guarantee</span>
</div>
<div class="number-of-lessons col-1-item">
<span>Number of lessons</span>
</div>
<div class="number-of-users col-1-item">
<span>Number of users</span>
</div>
<div class="country col-1-item">
<span>Based in country</span>
</div>
<div class="support col-1-item">
<span>Support</span>
</div>
<div class="video-lessons col-1-item">
<span>Video lessons</span>
</div>
<div class="downloadable-files col-1-item">
<span>Downloadable files</span>
</div>
</div>
<div class="feature-item">
<div class="price-item col-2-item">
<span>From xx to xx</span>
</div>
<div class="money-back-item col-2-item">
<span>30 days</span>
</div>
<div class="number-of-lessons-item col-2-item">
<span>300+</span>
</div>
<div class="number-of-users-item col-2-item">
<span>35k +</span>
</div>
<div class="country-item col-2-item">
<span>UK</span>
</div>
<div class="support-item col-2-item">
<span>24/7 live chat support </span>
</div>
<div class="video-lessons-item col-2-item">
<span>Yes</span>
</div>
<div class="downloadable-files-item col-2-item">
<span>Yes</span>
</div>
</div>
</div>
I suggest use instead of div and use CSS for border or other style
<table>
<tr>
<td>PRICE</td>
<td>From XX to XX</td>
</tr>
</table>
I'm making an EJS-based site with Express on the back end. I have a page which is dynamically populated. I'm trying to write scss which targets the last img.collab-img element in each div.year-box
The html looks a bit like this, once it's loaded in the browser ...
<div class="content-box">
<div class="year-box">
<p>2021</p>
<p>...</p>
<a>
<div class="credits credits-flex">
<span class="no-text-decoration">
...
</span>
<span class="link-arrow">
→
</span>
</div>
<img class="collab-img" src="" alt="">
</a>
</br>
<a>
<div class="credits credits-flex">
<span class="no-text-decoration">
...
</span>
<span class="link-arrow">
→
</span>
</div>
<img class="collab-img" src="" alt="">
</a>
</br>
</div>
<div class="year-box">
<p>2020</p>
<p>...</p>
<a>
<div class="credits credits-flex">
<span class="no-text-decoration">
...
</span>
<span class="link-arrow">
→
</span>
</div>
<img class="collab-img" src="" alt="">
</a>
</br>
<a>
<div class="credits credits-flex">
<span class="no-text-decoration">
...
</span>
<span class="link-arrow">
→
</span>
</div>
<img class="collab-img" src="" alt="">
</a>
</br>
<a>
<div class="credits credits-flex">
<span class="no-text-decoration">
...
</span>
<span class="link-arrow">
→
</span>
</div>
<img class="collab-img" src="" alt="">
</a>
</br>
</div>
</div>
I tried
.year-box {
img:last-of-type {
border: 1px solid black;
}
}
but it applied to style to all of the images, not only the last one in each year-box.
I answered my own question. The selector which worked was...
.year-box a:last-of-type img { }
I am trying to display 4 similar cards in a grid. I am able to create the columns however the card actions only apply to the first one. (On click, an overlay appears with a 'view details' button and a further description about the product).
On hovering over the other 3 cards, nothing happens. Only the first one works.
<div class="container_grid">
<div class="row">
<div class="col-3">
<div id="product-card" style="margin: 1rem">
<div id="product-front">
<div class="shadow"></div>
<img src="https://veenaazmanov.com/wp-content/uploads/2019/08/Chocolate-Birthday-Cake5-500x500.jpg" alt="" />
<div class="image_overlay"></div>
<div id="view_details">View details</div>
<div class="stats">
<div class="stats-container">
<span class="product_price">Ksh.500</span>
<span class="product_name">Chocolate Cake</span>
<p>Tasty cake</p>
<div class="product-options">
<strong>Available in</strong>
<span>1kg, 2kg, 3kg, 4kg, 5kg</span>
<button class="btn">Add To Cart</button>
<!-- <div class="cart_btn"><p>Add to Cart</p></div> -->
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-3">
<div id="product-card" style="margin: 1rem">
<div id="product-front">
<div class="shadow"></div>
<img src="https://veenaazmanov.com/wp-content/uploads/2019/08/Chocolate-Birthday-Cake5-500x500.jpg" alt="" />
<div class="image_overlay"></div>
<div id="view_details">View details</div>
<div class="stats">
<div class="stats-container">
<span class="product_price">Ksh.500</span>
<span class="product_name">Chocolate Cake</span>
<p>Tasty cake</p>
<div class="product-options">
<strong>Available in</strong>
<span>1kg, 2kg, 3kg, 4kg, 5kg</span>
<button class="btn">Add To Cart</button>
<!-- <div class="cart_btn"><p>Add to Cart</p></div> -->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
What could be the problem?
Link to the full JFiddle https://jsfiddle.net/5yoerguh/1/
The problem is you use id for div, need change it to class
or use this selector $('.col-3 > div').hover(function(){}
https://jsfiddle.net/viethien/2nesgtLy/1/
I created chatbox UI for my Application. I want to add scroll bar for the chatbox. I added the overflow-y:auto; in chat-content div class. But it doesn't work.If I add the style in chat div class it will work both messages and input box also. But I need scroll only messages. I don't know where to add the overflow-y:auto;
Any one please find the solution for me.
Here I attached the html code for chatbox.
I followed this tutorial:
https://codepen.io/CodeFrogShow/pen/PKYvMo
html:
<div class="container_chatbot">
<div class="app">
<div class="head clearfix">
<span class="messages-notification">
<i class="fa fa-comments-o"></i>
<span class="count"></span>
</span>
<span class="title">Messenger</span>
<span class="create-new">
<a (click) = "onVisible()" class="close">
<i class="material-icons">expand_more</i>
</a>
</span>
</div>
<div class="body">
<div class="friend-list clearfix">
<ul>
<li class="active">
<span class="messages hide">
<span class="count"></span>
</span>
<img src="https://s5.postimg.org/3wnxyjz8n/image.png" alt="" />
<span class="name">
Jiffy
</span>
</li>
</ul>
</div>
<div class="chat-messages">
<div class="chat">
<div class="chat-content clearfix" >
<span *ngFor= "let message of messages_receiver" class="friend last">
{{message}}
</span>
<span *ngFor= "let message of messages_sender" class="you first">
{{message}}
</span>
</div>
<div class="msg-box">
<input type="text" [(ngModel)]= "message" class="ip-msg" placeholder="type something.." />
<span class="btn-group">
<a (click) = "send()" >
<i class="fa fa-paper-plane"></i>
</a>
</span>
</div>
</div>
</div>
</div>
</div>
Is there any method in WWW::Selenium which will allow me to iterate through this structure (HTML code) and access the hrefs?
<div class="myGengo_wrap full_width">
<h1>Dashboard</h1>
<div class="blue list">
<span class="title">Sections </span>
<span class="dashboard_master_language">
<span class="dashboard_language wide">
Englisch (Master)
</span>
</span>
<span class="dashboard_languages">
<span class="dashboard_language wide">
Chinese
</span>
<span class="dashboard_language wide">
German
</span>
</span>
...
...
</div>
There is a get_all_links method - see the documentation.