Solved

Bootstrap 3 and Angular 2

Posted on 2016-11-20
12
83 Views
Last Modified: 2016-11-24
Hello there,

I am developing a web application and using Bootstrap 3 and Angular 2 for front end. Now I want to show some thumbnails to the user when they login. For this I am using the thumbnail class from bootstrap and the image for them i want to use Glyphs icons. Can somebody please help me how I can add these icons in the thumbnails.

cheers
Zolf

<div class="container" ">
    <div class="row">
      <div class="col-xs-6 col-md-3">
        <a href="#" class="thumbnail">
          <img src="" alt="">
        </a>
      </div>
    </div>
  </div>

Open in new window

0
Comment
Question by:zolf
  • 6
  • 6
12 Comments
 
LVL 54

Expert Comment

by:Julian Hansen
ID: 41895588
Which icons do you want to use - this is how you insert a glyphicon in your code
<div class="container" ">
    <div class="row">
      <div class="col-xs-6 col-md-3">
        <a href="#" class="thumbnail">
          <span class="glyphicon glyphicon-user"></span>
        </a>
      </div>
    </div>
  </div>

Open in new window

0
 
LVL 54

Expert Comment

by:Julian Hansen
ID: 41895590
You can potentially loose the thumbnail class - is there any particular reason you need it?
0
 

Author Comment

by:zolf
ID: 41895600
thanks for your comments. I am trying to use this http://glyphicons.com/
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 54

Expert Comment

by:Julian Hansen
ID: 41895718
Then this question does not have anything to do with Angular or Bootstrap. BS glyphicons rely on a font file - whereas these are straight PNG files.

So for what you want you either have to create the image
<img src="path/to/glyphicons/png/glyphicons-social-8-amazon.png" />
And then style the image or
Or you need to create a class to make the icon a background image.

It depends on how you plan to use them - if they are just going to be links as in your sample then
<div class="container" ">
    <div class="row">
      <div class="col-xs-6 col-md-3">
        <a href="#" class="thumbnail">
          <img src="path/to/icon.png" alt="">
        </a>
      </div>
    </div>
  </div>

Open in new window

You can read more about Bootstrap Glyphicons here  http://getbootstrap.com/components/
0
 

Author Comment

by:zolf
ID: 41896974
Thanks for your feedback. I am trying to achieve this layout in bootstrap. Can you say by looking at it what I need to use thumnail or button or something else. thanks!!

1
0
 

Author Comment

by:zolf
ID: 41897033
By the way can you please explain how these glyphs icons work with relation to Bootstrap. I mean do I need to save these icons in a folder before I can use them or it is already in the Bootstrap package.
0
 
LVL 54

Expert Comment

by:Julian Hansen
ID: 41897152
Do you mean these http://glyphicons.com/

They are separate from BS and don't integrate the way the Bootstrap included glyphicons work - which are implemented as a font. The advantage of a font is you can scale it and colour it - whereas a PNG you are stuck with what you get.
0
 

Author Comment

by:zolf
ID: 41897277
Appreciate your help. Can you please comment on what structure I need to use to achieve that layout. Am I correct to use thumbnail.
0
 
LVL 54

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 41897405
I don't have the time to do a proper sample but here is a rough and ready

CSS
<style type="text/css">
.glyphbutton {
	background: url(images/t1889.sprite.png) no-repeat 0 0;
	width: 161px;
	height: 168px;
	display: table-cell;
	vertical-align: bottom;
}
.glyphbutton.two {
	background-position: 0 -161px;
}
.glyphbutton.three {
	background-position: 0 -322px;
}
.glyphbutton.four {
	background-position: 0 -483px;
}
.glyphbutton.five {
	background-position: 0 -644px;
}
</style>

Open in new window

HTML
	<div class="row">
		<button class="glyphbutton"></button>
		<button class="glyphbutton two"></button>
		<button class="glyphbutton three"></button>
		<button class="glyphbutton four"></button>
		<button class="glyphbutton five"></button>
	</div>

Open in new window

Sprite-t1889.sprite.pngWorking sample here
0
 

Author Closing Comment

by:zolf
ID: 41900659
Cheers
0
 

Author Comment

by:zolf
ID: 41900663
By the way how are you assigning the buttons its image?.can you please explain
0
 
LVL 54

Expert Comment

by:Julian Hansen
ID: 41900679
As a background. I am using a sprite - which I shift up with CSS for each button.
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question