I have designed a card-shaped rectangle, that has an inside integer value which is obtained from an angular module/class/type script.... I want to change the height of the shape based on the inside value: the larger the value, the longer the height of the rectangle.
so far, this is my code
<div class = "card">
<div class="content">
<p id = "name">
{{Card.lesson.Name}}
</p>
<p id = "time">
{{Card.duration.Hours}}
<span>
:
{{Card.duration.Minutes}}
</span>
</p>
</div>
<div class = "shape">
</div>
</div>
.card
{
width : 100px;
height : 150px;
background :#FFFFFF;
border: 1px solid #EEE2FA;
border-radius : 10px;
position: relative;
}
#name
{
position: relative;
text-align:center;
font-size:15px;
top:30px;
}
#time
{
position: relative;
text-align:center;
font-size:15px;
top:50px;
}
.shape
{
position: absolute;
display: block;
height:85%;
width: 3px;
background-color: blue;
padding-top: 0px;
top: 10px;
border-radius: 4px;
right: auto;
left: 8px;
padding-left: 8px;
}
The problem is, I have no Idea how to do so. how can I possibly relate Card.Duration.Hours to the height of the card?
You can use ngStyle to do so
You code will be like this:
<div class = "card" [ngStyle]="{'height': Card.duration.Hours + 'px'}">
<div class="content">
<p id = "name">
{{Card.lesson.Name}}
</p>
<p id = "time">
{{Card.duration.Hours}}
<span>
:
{{Card.duration.Minutes}}
</span>
</p>
</div>
<div class = "shape">
</div>
</div>
You can specify your own unit intead of px
Hope it helps.
Related
I'm setting up some conceptual functions (hence the probably botched way this is put together), but I'm running into an unforeseen issue with using position : absolute on the toast elements. On the right-hand products there's no issue besides the toast overlapping the products to its left (which is fine in this case), but when it triggers on the left column it extends outside the viewport.
That's why the class="diamond" is outside the toast itself, so that it can remain static regardless of the toast's position, since I assume position : absolute is not the ideal positioning for the toast.
So my question is, how can I achieve the intended effect of the toast triggering but remaining inside the viewport? My intention is for the diamond to be "anchored" to the button, with the toast itself dynamic on the horizontal axis.
Click the red square to open the toast, and the green one inside to close it.
function open(event) {
if (!event.target.closest(".product button")){
return false;
}
const parent = event.target.closest(".product");
const toast = parent.querySelector('.toast');
const diamond = parent.querySelector('.diamond');
toast.style.display = 'block';
diamond.style.display = 'block';
}
function close(event) {
if (!event.target.closest(".toast button")){
return false;
}
const product = event.target.closest(".product");
const toast = event.target.closest(".toast");
product.querySelector('.diamond').style.display = 'none';
toast.style.display = 'none';
}
addEventListener('click', open);
addEventListener('click', close);
.container {
display : flex;
flex-flow: row wrap;
justify-content : space-around;
height : 450px;
width : 300px;
background-color : grey;
}
.product {
position : relative;
height : 200px;
width : 130px;
background-color : blue;
}
.icon {
position : absolute;
top : 10px;
right : 10px;
height : 30px;
width : 30px;
background-color : red;
}
.diamond {
position : absolute;
display : none;
height : 10px;
width : 10px;
top : 50px;
right : 20px;
background-color : black;
transform : rotate(45deg);
}
.toast {
position : absolute;
display : none;
width : 160px;
height : 50px;
top : 55px;
right : 10px;
background-color : black;
border-style: solid;
border-width : thin;
border-color : red;
}
.close {
position : absolute;
display : block;
width : 20px;
height : 20px;
top : 15px;
right : 70px;
background-color : green;
}
<div class="container">
<div class="product">
<button class="icon"></button>
<div class="diamond"></div>
<div class="toast">
<button class="close"></button>
</div>
</div>
<div class="product">
<button class="icon"></button>
<div class="diamond"></div>
<div class="toast">
<button class="close"></button>
</div>
</div>
<div class="product">
<button class="icon"></button>
<div class="diamond"></div>
<div class="toast">
<button class="close"></button>
</div>
</div>
<div class="product">
<button class="icon"></button>
<div class="diamond"></div>
<div class="toast">
<button class="close"></button>
</div>
</div>
</div>
This can be the possible solution. Please replace toast css with the below css:
.toast {
position: absolute;
display: none;
width: 100%;
height: 50px;
top: 55px;
right: 0;
background-color: black;
border-style: solid;
border-width: thin;
border-color: red;
}
Hope this will help you!
I'm trying to change the size of my 'Send' button but it is not responding. I know it should be a simple fix but I'm not sure about the exact reason why this is happening. I was wondering if anyone could help me out. Thanks.
Here is the CSS:
.send{
border-radius: 20px;
background-color: #00e699;
font-weight: bold;
color: white;
position:relative;
width: 80%;
height: 80%;
top: 50px;
left: 32%;
}
Here is the HTML containing the 'send' button
<div class="infocard">
<div class = "col-md-12" >
<h3 class="theName"></h3>
<h3 class="theNum"></h3>
<h3 class="theDate"></h3>
<input type = "text" name = "Name" size = "30" class = "textBox" ng-model = "input" />
Send Message
</div>
</div>
Just add display type as desired
.send{
border-radius: 20px;
background-color: #00e699;
font-weight: bold;
color: white;
position:relative;
width: 50%;
height: 80%;
top: 50px;
left: 32%;
display:block;
}
<div class="infocard">
<div class = "col-md-12" >
<h3 class="theName"></h3>
<h3 class="theNum"></h3>
<h3 class="theDate"></h3>
<input type = "text" name = "Name" size = "30" class = "textBox" ng-model = "input" />
Send Message
</div>
</div>
a tags are display: inline by default. You need to add display: block or display: inline to add width/height styles.
So I have an image and some text inside a border. I'm trying to have a word on the border itself and I can't seem to find a way of doing it.
my HTML
<div class="img">
<img src="https://imagizer.imageshack.us/v2/321x396q90/661/oUF8n3.jpg" align="left" height=400px width=400px alt="sliced">
<div class="text">
Calibre: From 1 up to 5 mm <br>
Packing: jute or polypropylene bags , Vacuum & Carton <br>
Usage areas: It is used as the raw material for processed and fully processed hazelnuts, etc. <br>
</div>
<h2> Sliced </h2>
</div>
CSS
.img {
float: left;
border-style: solid;
border-width: 2px;
border-color: 24AB36;
padding: 20px;
}
I want the header 2 to be on the border.
How do I do this ?
if you want a text on the border ,you can use fieldset
SEE DEMO
<fieldset>
<legend>Title Text</legend>
CONTENT HERE
</fieldset>
Html:
<fieldset class="field_set">
<legend style="text-align: center;"><h2>Sliced</h2></legend>
<div class="img">
<img src="https://imagizer.imageshack.us/v2/321x396q90/661/oUF8n3.jpg" align="left" height=400px width=400px alt="sliced">
<div class="text">
Calibre: From 1 up to 5 mm <br>
Packing: jute or polypropylene bags , Vacuum & Carton <br>
Usage areas: It is used as the raw material for processed and fully processed hazelnuts, etc. <br>
</div>
</div>
</fieldset>
CSS:
.img {
float: left;
padding: 20px;
}
.field_set{
border-width:6px;
border-color:#F00;
border-style: solid;
}
I can't see how the text could fit into your div's 2px border, so I assume you mean the padding.
In that case, set .img's position to relative, set h2's position to absolute, and use some guesswork to manoeuvre it into the padding using top and left properties.
http://jsfiddle.net/prashanthcr/p2zmc4o5/1/
.img {
<other properties omitted for brevity>
position: relative;
}
h2 {
position: absolute;
top: 395px;
left: 180px;
}
Fieldset may work, but the fieldset tag is usually used within a form to group controls/input elements, like a group of checkboxes.
It may be a little more semantically correct to just style and position your h2 like so:
body {
padding: 20px;
}
.img {
float: left;
border-style: solid;
border-width: 2px;
border-color: 24AB36;
padding: 20px;
position: relative;
}
.img h2 {
position: absolute;
background: white;
top: -1.65em;
}
<div class="img">
<h2> Sliced </h2>
<img src="https://imagizer.imageshack.us/v2/321x396q90/661/oUF8n3.jpg" align="left" height=400px width=400px alt="sliced">
<div class="text">
Calibre: From 1 up to 5 mm
<br>Packing: jute or polypropylene bags , Vacuum & Carton
<br>Usage areas: It is used as the raw material for processed and fully processed hazelnuts, etc.
<br>
</div>
</div>
Or if you're not as concerned about, semantics you could use a pseudo element like so:
.img::before {
content: "Sliced";
font-size: 2em;
position: absolute;
background: white;
top: -0.75em;
left: 0.75em;
}
body {
padding: 20px;
}
.img {
float: left;
border-style: solid;
border-width: 2px;
border-color: 24AB36;
padding: 20px;
position: relative;
}
.img::before {
content: "Sliced";
font-size: 2em;
position: absolute;
background: white;
top: -0.75em;
left: 0.75em;
}
<div class="img">
<img src="https://imagizer.imageshack.us/v2/321x396q90/661/oUF8n3.jpg" align="left" height=400px width=400px alt="sliced">
<div class="text">
Calibre: From 1 up to 5 mm
<br>Packing: jute or polypropylene bags , Vacuum & Carton
<br>Usage areas: It is used as the raw material for processed and fully processed hazelnuts, etc.
<br>
</div>
</div>
I need to display a table via ng-grid, but the table has a <caption> tag. See the yellow section in the image below. How can I achieve it?
ng-grid uses divs, not tables. You can use a custom headerRowTemplate to achieve a similar result, however.
The default header row template is here: https://github.com/angular-ui/ng-grid/blob/master/src/templates/headerRowTemplate.html
You can create your own and add a row on top, then reference it with the headerRowTemplate option in your grid options:
<script type="text/ng-template" id="myHeaderTemplate">
<div>
<div class="headerTop ngHeaderCell">
<span class="content">Submissions</span>
</div>
<div style="height: 30px; top: 30px; position: absolute">
<div ng-style="{ height: col.headerRowHeight }" ng-repeat="col in renderedColumns" ng-class="col.colIndex()" class="ngHeaderCell">
<div class="ngVerticalBar" ng-style="{height: col.headerRowHeight}" ng-class="{ ngVerticalBarVisible: !$last }"> </div>
<div ng-header-cell></div>
</div>
</div>
</div>
</script>
Make sure that the header container is sized to hold both the column headers and your caption:
.ngHeaderContainer, .ngHeaderScroller {
height: 60px !important;
}
And add styles for the caption:
.headerTop {
height: 30px;
width: 100%;
border-bottom: 1px solid #ccc;
background-color: #FFD700;
padding: 0px 0 0 6px;
}
.headerTop .content {
padding: 6px;
position: absolute;
bottom: 0;
top: 0;
color: #fff;
}
Here's a demonstration plunker:
http://plnkr.co/edit/fT1IrO?p=preview
How do I create centered <h1> with <hr/> on both sides over a background image?
I also need it to handle various text lengths, scale well for mobile viewing and have the <hr/> go to 100% width of its container.
I want this look, but over a background image.
There are lots of answers (here, here here and here) for text with lines on either side but all of them rely on using a solid background colour behind the text, which doesn't work for me as the page I want to put this on has a background image.
Here is how I achieve the look above, which handles various lengths of text and scales well:
CSS
.title-box {
height: 2px;
background-color: rgb(215, 0, 0);
text-align: center;
}
.title-outer {
background-color:rgb(230, 230, 230);
position: relative;
top: -0.7em;
}
.title-inner {
margin:0px 20px;
font-size: 17.5px;
font-weight:bold;
color:rgb(100, 100, 100);
}
HTML
<div class="title-box">
<span class="title-outer">
<span class="title-inner">OUR STORY</span>
</span>
</div>
I have tried the method below and it kind of works but it doesn't handle various text widths or scale well due to the <h1> and the <hr/>s being in seperate <div>s:
HTML
<div class="row">
<div class="span4"><hr /></div>
<div class="span4"><h4>OUR STORY</h4></div>
<div class="span4"><hr /></div>
</div>
Note: This is example is using the Bootstrap grid system but that is not part of the problem/solution.
So any ideas how I can get the same look and behaviour but without the backgound colour for the text so it can sit over a background image?
No need JS, here is a pure CSS solution.
CSS
.title-hr hr {
display: inline-block;
width: 30%;
margin: 5px 10px;
border-top: 1px solid #e5e5e5;
}
HTML
<h1 class="title-hr"><hr />My Title<hr /></h5>
Result: http://jsfiddle.net/yptmftr4/
Ok, I've played a bit with this code and here is my solution. Yes, it's a bit dirty because I've used :before and :after, but works.
HTML
<div class="title-box">
<span id="first" class="title-inner">OUR LOOOoo oooo oOONG STORY</span>
</div>
<div class="title-box">
<span id="second" class="title-inner">OUR STORY</span>
</div>
<div class="title-box">
<span id="third" class="title-inner">STORY</span>
</div>
CSS
.title-box {
text-align: center;
}
.title-inner {
margin:0px 20px;
font-size: 17.5px;
font-weight:bold;
position: relative;
color:rgb(100, 100, 100);
}
.title-inner:after, .title-inner:before {
content:"";
float: right;
position: relative;
top: 8px;
height: 2px;
background: red;
}
.title-inner:before {
float: left;
}
jQuery
$(document).ready(function () {
function work() {
$(".title-inner").each(function () {
var full_width = $(window).width();
var id = $(this).attr("id");
var title_width = $("#" + id).width();
var new_width = (full_width - title_width) / 2 - 40;
$('head').append("<style>#" + id + ":before, #" + id + ":after{width:" + new_width + "px !important;}</style>");
});
}
work();
$(window).resize(function () {
work();
});
});
http://jsfiddle.net/ffb3X/4/
Because :before and :after are not part of DOM, I've used .append() function to append style tags in head for every title.
This code will on page load calculate everything, so it's responsive.
This code was posted originally by Arbel but his/her answer disappeared for some reason? I am reposting it (including some mods I've made) because it was the solution I ended up using. Credit where credit is due.
Working jsFiddle: http://jsfiddle.net/pA5Gu/
HTML
<div class="title-box">
<fieldset class="title-outer">
<legend id="titleInner" class="title-inner">OUR STORY</legend>
</fieldset>
</div>
CSS
.title-box {
background-image: url('http://imagezo.com/images/1302-green-bubbles-awesome-background-wallpaper.jpg');
height:100%;
}
.title-outer {
border-top:2px solid rgb(215, 0, 0);
background-color: transparent;
}
.title-inner {
width:auto;
padding:0px 20px;
border: 0;
background-color: transparent;
font-size: 17.5px;
font-weight:bold;
color:rgb(255, 255, 255);
}
jQuery
$(document).ready(function() {
var legendWidth = $('#titleInner').outerWidth();
var margin = 'calc((100% - '+legendWidth+'px) / 2)';
$('#titleInner').css('margin-left', margin);
$('#titleInner').css('margin-right', margin);
});
http://jsfiddle.net/habo/HrfuH/1/
<div class="title-box">
<div class="myContent">
<div class="title-outer"><hr /></div>
<div class="title-inner "><h4>OUR STORY</h4></div>
<div class="title-outer"><hr /></div>
</div>
</div>
.myContent{
display:block;
width:600px;
margin:0 auto;
}
.title-box {
background:#eee;
height:60px;
}
.title-outer{
}
hr {
height: 2px;
background-color:rgb(215, 0, 0);
margin: 2em 0;
width:25%;
float:left;
}
.title-inner {
margin:0px 20px;
font-size: 17.5px;
font-weight:bold;
color:rgb(100, 100, 100);
float:left;
}