• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

insert graphic icon between text words, inline-block

Enthusiast ,
Jan 24, 2017 Jan 24, 2017

Copy link to clipboard

Copied

Would like a graphic file of a small icon to be within the same sentence between text based words. Don't want any wrapping of the line as soon as it comes to the img icon. Want the small image to flow along with the text.

<p>Refer to this icon <div class="icon" alt="icon"></div>when accessing the activity.</p>

.icon {

    width: 24px;

    height: 23px;

    background: url('../img/icon.jpg') no-repeat;

    display: inline-block;

    }   

Do I need to add a display property to the <p> tag to better support this?

Thank you.

Views

4.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 24, 2017 Jan 24, 2017

Are you using the same icon as a bullet in a list?

<ul>

     <li>some item</li>

     <li>some item</li>

     <li>some item</li>

</ul>

Or a unique icon for each line?

Use a <span> tag.

<p><span class="glyphicon glyphicon-alert"></span> Some text here</p>

Votes

Translate

Translate
Community Expert ,
Jan 24, 2017 Jan 24, 2017

Copy link to clipboard

Copied

Are you using the same icon as a bullet in a list?

<ul>

     <li>some item</li>

     <li>some item</li>

     <li>some item</li>

</ul>

Or a unique icon for each line?

Use a <span> tag.

<p><span class="glyphicon glyphicon-alert"></span> Some text here</p>

Nancy O'Shea— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 24, 2017 Jan 24, 2017

Copy link to clipboard

Copied

Just to add to Nancy's reply, there are a number of ways depending on what you want. The methods that I have used for inline icons is to use Font Awesome, which is similar to glyphicon and to use an SVG.

The former looks like

The code looks like

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>Untitled Document</title>

<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />

</head>

<body>

<h2>Font Awesome Demo</h2>

<p>I like to use photography <i class="fa fa-camera"></i></p>

<p>after which we will do some fine dining <i class="fa fa-cutlery"></i></p>

<p>To see more, go to <a href="http://fontawesome.io/">Font Awesome</a> <i class="fa fa-external-link"></i></p>

</body>

</html>

Wappler, the only real Dreamweaver alternative.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 24, 2017 Jan 24, 2017

Copy link to clipboard

Copied

I use Font Awesome too because I think they look better and have more icon choices.

Glyphicons are still supported in Bootstrap 3 but not in Bootstrap 4.

Nancy O'Shea— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 25, 2017 Jan 25, 2017

Copy link to clipboard

Copied

Oh yes, and I do use Font Awesome and glyphicons, but in this case it is a custom icon, a graphic.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 25, 2017 Jan 25, 2017

Copy link to clipboard

Copied

.icon-right{

  width: 30px; // specify the dimensions

  height: 18px;

  display: inline-block; // by default, but just to make sure

  vertical-align: middle; // vertical alignment

  position: relative; // to allow micro alignment

  top: -1px; // micro alignment

  margin-left: 4px; // keep the distance from the text

}

Edit:

The HTML

This is my inline image <img src="img/myImage.png" class="icon-right" alt="">

Wappler, the only real Dreamweaver alternative.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 25, 2017 Jan 25, 2017

Copy link to clipboard

Copied

LATEST

Bootstrap has a class.

<p>Here is some text <img class="display-inline" src="your_image.jpg" alt="icon"></p>

Nancy

Nancy O'Shea— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines