/    Sign up×
Community /Pin to ProfileBookmark

CSS: Why does the cross sign look normal instead of being italic?

Hello

I basically transcribed the following code from a video tutorial which teaches how to close a quick code if click the cross sign ×.

I have some questions on the code. Would you please help me out?

(1) Why does the multiple sign appear normally on the webpage instead of being italic as the multiple sign is being marked with ‘i’.

However if I replace multiple sign (×) with English letter (X), the English X will become italic.

These are what I am talking about.

>

<!– <i class=’close-btn’>X</i> –>
> <i class=”close-btn”>×</i>

(2) I don’t figure out why the coach especially writes the font-family for a cross sign here. What is his purpose here if you can guess this?

>

font-family: Arial, Helvetica, sans-serif;

I feel this is relevant to the first question above. If he just wants to make the cross sign normal, why doesn’t he write font-size: normal?

Thank you very much!

[code]
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<title>Document</title>
<style>
.box {
position: relative;
width: 74px;
height: 88px;
margin: 100px auto;
border: 1px solid #ccc;
color: #f40;
font-size: 12px;
text-align: center;
background-color: pink;
}
.box img {
width: 60px;
margin-top: 5px;
}
.close-btn {
position: absolute;
top: -1px;
left: -16px;
width: 14px;
height: 14px;
border: 1px solid #ccc;
font-family: Arial, Helvetica, sans-serif;
cursor: pointer;
}
</style>
</head>
<body>

<div class=”box”>
Hello
<img src=”images/tao.png” alt=””>
<!– <i class=’close-btn’>X</i> –>
<i class=”close-btn”>×</i>
</div>
<script>
var box = document.querySelector(‘.box’);
var btn = document.querySelector(‘.close-btn’);
btn.onclick = function() {
box.style.display = ‘none’;
}
</script>

</body>
</html>

[/code]

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@FijjitMar 26.2020 — 
  • 1. I tried placing your multiply sign in italics, and it does seem to work - the symbol is slanted. Here's what I tried:

    &lt;i&gt;×&lt;/i&gt;


  • 2. I'd guess that the coach wanted to ensure the close button has a sans-serif font, while the rest of the page might have something else.

    3.
  • Copy linkTweet thisAlerts:
    @EdwinEMoraMar 30.2020 — Hello, you need to create a button using a div tag and assign the ID close-btn to your element. I created many close functions on educational websites like https://au-assignmenthelp.com/ that is based on assignment help for students, and you can take advice from this resource to write your essays and assignments.
    Copy linkTweet thisAlerts:
    @HarshShahApr 17.2020 — Heyy,

    Try like this it can be work...

    HTML :
    ``<i>
    </i>&lt;div class="wrapper"&gt;
    &lt;img src="images/tao.png" alt=""&gt;
    &lt;span class="close"&gt;&lt;/span&gt;
    &lt;/div&gt;<i>
    </i>
    `</CODE>

    CSS :
    <CODE>
    `<i>
    </i>.wrapper {
    position: relative;
    display: inline-block;
    }
    .close:before {
    content: '✕';
    }
    .close {
    position: absolute;
    top: 0;
    right: 0;
    cursor: pointer;
    }<i>
    </i>
    `</CODE>

    JS :
    <CODE>
    `<i>
    </i>document.querySelector('.close').addEventListener('click', function() {
    console.log('close');
    });<i>
    </i>
    ``
    ×

    Success!

    Help @tree123 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 4.27,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...