简体   繁体   English

如何为span类添加样式

[英]How to add style to a span class

sorry for the silly question by I'm new to html5 and css and mainly just using templates in joomla. 抱歉这是一个愚蠢的问题,我是html5和css的新手,主要只是在joomla中使用模板。 I want to add share this buttons to my template file so I've got the code from the share this site and added the buttons no problem. 我想将此按钮添加到我的模板文件中,所以我从共享此站点获得了代码并添加了按钮没有问题。 The issue I have is centering the buttons. 我的问题是按钮居中。 Not sure what styling I need to add and where, thanks in advance for any pointers... 不确定我需要添加哪些样式以及在哪里,提前感谢任何指针......

How do I tell these to sit in the middle of the page? 我怎么告诉这些坐在页面中间? Not sure where / how to add text align... 不知道在哪里/如何添加文本对齐...

<span class='st_facebook_large' displayText='Facebook'></span>
<span class='st_twitter_large' displayText='Tweet'></span>
<span class='st_googleplus_large' displayText='Google +'></span>
<span class='st_linkedin_large' displayText='LinkedIn'></span>
<span class='st_email_large' displayText='Email'></span>

You need a div to put those spans into to center them all. 你需要一个div来将这些跨度放在中心位置。 like this. 像这样。

<div style="text-align: center">

<span class='st_facebook_large' displayText='Facebook'></span>
<span class='st_twitter_large' displayText='Tweet'></span>
<span class='st_googleplus_large' displayText='Google +'></span>
<span class='st_linkedin_large' displayText='LinkedIn'></span>
<span class='st_email_large' displayText='Email'></span>

</div>

You can do it two ways. 你可以用两种方式做到。 You can either have an external style sheet in which you place all of your classes and ID styles, or you can use the style=""; 您可以使用外部样式表来放置所有类和ID样式,也可以使用style =“”; within the context of the span. 在跨度的范围内。 So for example: 例如:

CSS CSS

.st_email_large {
    margin:0 auto;
    width: 300px;
    text-align: center;
}

In this case the (( . )) represents a class and everything within the brackets is what your span will do. 在这种情况下,((。))表示一个类,括号内的所有内容都是您的范围所做的。 Or you can do this: 或者你可以这样做:

<span class='st_email_large' style="margin:0 auto; width: 300px; text-align: center;" displayText='Email'></span>

If you use a external style sheet, you need to make sure you include it into your page within the head tag. 如果使用外部样式表,则需要确保将其包含在head标记内的页面中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM