HTML Angular 8 - How to scale an img down - html

I'm creating a gallery of PDF's using the component.html below. It's nearly pure HTML except for the Angular *ngFor loop. The PDF icons are displayed, each one linking to a specific file. My problem is with the style="width: 100%;", it is meant to show up to four img's before wrapping to next line. But, the side-effect is that the img's scale to a large size. If you look at the screenshots below, the top image was produced using style="width: 25%;", the bottom one using 100%. I like the 25% size, but I want the label's to be below the image, like we see in the 100% size. The PDF image is actually 67px x 64px.
How to fix?
component.html
<div class="row">
<div *ngFor="let doc of docs">
<a href="#/gallery" (click)="showDoc(doc)">
<p style="float: left; font-size: 14pt; text-align: center; width: 25%; padding-left: 10px;">
<img src="{{doc.img}}" style="width: 100%;"><b>{{doc.lbl}}</b>
</p>
</a>
</div>
<p style="clear: both;"></p>
</div>
screenshots

Please use the below code . I have used inline CSS for the example ( you can place it to your css & use it from the there). Here I have used 50px image height you can use as per your requirements
style="max-width: 100%; height:50px"
HTML:
<div class="container">
<div class="row">
<div *ngFor="let doc of docs" class="col-md-4">
<a href="#/gallery" (click)="showDoc(doc)" style="float: left; font-size: 14pt; text-align: center; width: 25%; padding-left: 10px;">
<span>
<img src="https://techterms.com/img/lg/pdf_109.png" style="max-width: 100%; height:50px"><b style="display: block;">{{doc.lbl}}</b>
</span>
</a>
</div>
</div>

Related

How to make text in Flexbox, not defining width of flexbox?

I have this issue: I have flexbox with 3 photos in the center of the screen.
under these photos, I have some text like mobile number etc.
When I add this text into this boxes, this text is defining the width of my box, and it's moving boxes and they are not in the center anymore.
Final result should be: The box width should be the same but text should break and be centered.
Here you can see size of one box
Here you can see size od the other box
Snippet:
.ikony {
padding-top: 60px;
display: inline-flex;
justify-content: center;
width: 100%;
font-weight: 600;
font-size: 16px;
color: #020E46;
text-align: center;
font-family: Open Sans,Arial,sans-serif;}
.column {
padding: 90px 70px 0px 70px;}
<div class="ikony">
<div class="column prvy">
<img src="img/mobil-icon.png" alt="iconka-mobil" width="100px" height="100px">
<div class="txtpod">
<p>+421 918 000 000</p>
</div>
</div>
<div class="column">
<img src="img/pin-icon.png" alt="ikona pinu" width="100px" height="100px">
<div class="txtpod">
<p>address 273/14, Svit</p>
</div>
</div>
<div class="column">
<img src="img/email.png" alt="ikona pinu" width="100px" height="100px">
<div class="txtpod">
<p>myemail#gmail.com</p>
</div>
</div>
</div>
Thanks for any advice
Add flex-grow: 0 and width: 33% to the flex items (.column) to prevent them to get wider.
However, if you have something like an email address in one of the containers that forces it to be wider than 33% because it contains no spaces and therefore can't break into several lines (like in your snippet example), you should use a small font that lets it fit into the 33% width.

BootStrap Row not aligning

I am using Bootstrap 4 Alpha 5 and I have the following HTML:
<div class="home-content">
<div class="container">
<div class="row flex-items-xs-middle">
<div class="col-md-7">
<h1 class="site-title text-xs-center text-md-left">
<span class="name">I'm Shivam Paw</span>
<span class="title">I create beautiful and bespoke websites to fit your needs</span>
</h1>
</div>
<div class="col-md-5">
<img src="https://www.shivampaw.com/wp-content/uploads/2016/10/shivampaw.png" class="float-md-right img-fluid logo-me mx-auto" alt="Shivam Paw">
</div>
</div>
</div>
</div>
However, if you see the image below then you will see that the content is misaligned to the left. I saw a post on this on SO but it said you have to put the row class in a container which I have already done.
You can see the site live at https://www.shivampaw.com
I looked at the .row CSS which has margin for left and right of -15px. Removing those margins fixed it but I don't think that's how it should be?
If this is what you expect then look at your CSS. This is the line centering your content
.text-xs-center {
text-align: center!important;
}
This should fix it though
.site-title {
font-size: 36px;
color: white;
font-weight: bold;
text-align: left !important;
}
Turns out I had some offending CSS in my style.css:
*, img.full-size{
max-width: 100%;
}
Changing it to:
img.full-size{
max-width: 100%;
}
Fixed the problem.

Need to create always to div

I am going to make a website like this http://watcherboost.com/
SO i want to create middle menu for my website.so i need to create a div tag which is always top on following background:
This is the code i tried
<form id="form1" runat="server">
<div>
<div id="top" style="background-color:#072530; height: 30px;margin-top: -10px;margin-left:auto;margin-right:initial">
</div>
</div>
</form>
<div style="height: 300px;background-color: #0E5D7B; margin-top: 0px;">
</div>
<div style="background-color:#072530; height: 30px;margin-top: -10px;margin-left:auto;margin-right:initial">
</div>
<div style="height: 650px; background-color: #C2C2C2; margin-top: 0px;">
</div>
<div style="background-color:#072530; height: 30px;margin-top: -10px;margin-left:auto;margin-right:initial">
</div>
<div style="height: 300px;background-color: #0E5D7B; margin-top: 0px;">
</div>
<div style="background-color:#072530; height: 30px;margin-top: -10px;margin-left:auto;margin-right:initial">
</div>
<div id="middle" style="margin-left: 150px;margin-right:150px;margin-top:-250px;background-color:black"></div>
I want to get this last div (id =middle) to always top mode like upper website.
But unfortunately my div (id=middle) is not showed the page..
Please advice how to edit this code
Thanks
Your div is not showing up, because it doesn't contain any content. Add height property to its inline CSS.
If you want a div stay on top you should set:
position:fixed;
top:0px;
try this:
https://jsfiddle.net/TiG3R/ug4vvo48/

css and html - why does a div which is float-left get placed on the line below?

I have HTML like this:
<div style="float: left; font-family: arial; padding-top: 40px; width: 655px; ">
<div style="float: left;">
<img src="http://www.problemio.com/img/big_logo.png" id="above_fold_img" style="border: none;" />
</div>
<div style="float: left; ">
<p>
<h1>mobile business plan, <br />
business ideas, fundraising<br /> and marketing apps
</h1> <!-- font-size: 200%; -->
</p>
</div>
<div style="clear:both;"></div>
And it looks like this. Here is a test page:
http://problemio.com/index_test.php
The blue B is supposed to be on the same line with the text. But possibly because the original image size is very big, it is getting screwed up in size.
Here is the css for the img:
img#above_fold_img
{
width: 30%;
height: 30%;
}
Would anyone know how to make the image and text appear on the same line?
Thanks!
You need to specify a width for both of the child <div>s. According to Chrome DevTools, the first <div> (with the child image) is 512px wide. width: 30%; on img#above_fold_img uses 30% of its parent div.Example:
<div style="float: left; width: 256px; height: 256px; margin: 0">
<img src="http://www.problemio.com/img/big_logo.png" id="above_fold_img" style="border: none; width: 256px; height: 256px" />
</div>
<div style="float: left; width: 393px; margin: 0; margin-left: 5px">
<p>
<h1>mobile business plan, <br />
business ideas, fundraising<br /> and marketing apps
</h1> <!-- font-size: 200%; -->
</p>
</div>
I kept all styles inline in my example, but using CSS is better. Also, the 'b' image is 512x512px. If you can shrink it, you will reduce load times.
I think just giving an answer helps but op wanted to know why as well..
You should declare a width on the image that contains the #above_fold_img so that the div takes on the same width that way you can do this
<div style="float: left; font-family: arial; padding-top: 40px; width: 655px;">
<div style="float: left;margin-right:20px">
<img src="http://www.problemio.com/img/big_logo.png" id="above_fold_img" width="154">
</div>
<div style="float: left;">
<p></p>
<h1>mobile business plan, <br>
business ideas, fundraising<br> and marketing apps
</h1> <!-- font-size: 200%; -->
<p></p>
</div>
<div style="clear:both;"></div>
</div>
Also you should try not to use <p></p> as spaces but use <br/> to do that
Change your div to have a width of 30% and the image to have a width of 100% or 90% for astetic reasons, so:
<div style="float: left; font-family: arial; padding-top: 40px; width: 655px;">
<div style="float: left; width: 30%;">
<img src="http://www.problemio.com/img/big_logo.png" id="above_fold_img" style="border: none;" />
</div>
and CSS:
img#above_fold_img
{
width: 100%;
height: 100%;
}

display inline not making the div to move upward

how to make the second div properly align with the first div....
i gave display inline for horizontal alignment...
but the second div is still down...
i am talking with respect to 24 inch monitor....
http://jsfiddle.net/ke6Se/1/embedded/result/
<div style=" width: 300px; display: inline-block;">
<span style="color: #000; font-size: 12px; font-family: arial; font-wieght: bold; margin-left: 45px;">Mark Up</span><span style="margin-left: 110px;">10%</span>
<div>
<span style="margin-left: 45px;">Non-Tax Amount</span><span style="margin-left: 59px;">0</span>
</div>
</div>
first of all, as Kevin said in his comment, you're html is wrong. You have one div nested inside the other. Fix that and then apply inline-block to the second div
<div style=" width: 300px; display: inline-block;">
<span style="color: #000; font-size: 12px; font-family: arial; font-wieght: bold; margin-left: 45px;">Mark Up</span><span style="margin-left: 110px;">10%</span>
</div>
<div style="display:inline-block">
<span style="margin-left: 45px;">Non-Tax Amount</span><span style="margin-left: 59px;">0</span>
</div>
Here's the obligatory fiddle
Your fiddle is really busy and I can't find exactly where it is, but it has to do with your margins and widths. You should set a wrapper <div> to a fixed width then float: right the <div> you want and make sure the <div>s widths add up to the wrappers width, including margin and any padding. See this article for a good explination.
http://www.webdesignerdepot.com/2012/09/when-pages-are-not-paper-the-designers-guide-to-layout-code/
Also it might help to set a min width to prevent stacking of divs when the window is shrinked if you don't want to set a static width.
Here is a quick HTML mark up of what I'm talking about.
<div id="wrapper" style="width: 800px;">
<div id="leftDiv" style="width: 600px; float: left;">
I'm the left Div!
</div>
<div id="rightDiv" style="width: 200px; float: right;">
I'm the right Div!
</div>
</div>