简体   繁体   English

如何在嵌入式CSS中定义CSS类?

[英]How do I define CSS class in an Inline CSS?

I want to create a popup screen appear when i click on an icon in my profile page of a game. 当我单击游戏个人资料页面中的图标时,我想创建一个弹出屏幕。 The developers have given us access to use HTML codes in our profile area, though using the STYLE tags are blocked. 尽管阻止了使用STYLE标签,但开发人员已使我们能够在个人资料区域中使用HTML代码。 Also I have no access to the head section of the HTML codes, as a result I cannot create any external file to define CSS class and link them to the profile page. 另外,我无权访问HTML代码的开头部分,因此,我无法创建任何外部文件来定义CSS类并将它们链接到配置文件页面。

Below I have created an example of my codes. 下面,我创建了一个代码示例。 In the example code I have created an external CSS code. 在示例代码中,我创建了一个外部CSS代码。 I want to know how can I get those external CSS into my HTML code (Using Inline CSS method). 我想知道如何将那些外部CSS放入HTML代码(使用内联CSS方法)。 My problem is defining the CSS class in an Inline CSS method. 我的问题是在嵌入式CSS方法中定义CSS类。

Things to know before answering my question: 在回答我的问题之前要知道的事情:

1) Cant create an external file for CSS. 1)无法为CSS创建一个外部文件。

2) Cant write codes inside the HEAD tags. 2)无法在HEAD标签内编写代码。

3) Cant use the STYLE tag. 3)不能使用STYLE标签。

4) Only HTML codes are allowed. 4)仅允许使用HTML代码。 BBCodes are not allowed. 不允许使用BBCode。

My HTML code looks like this: 我的HTML代码如下所示:

<p>
 <a class="button" href="#popup1">
  <img src="SOME ICON URL HERE">
 </a>
</p>

<div id="popup1" class="overlay light">
 <a class="cancel" href="#"></a>
 <div class="popup">
  <h2>TITLE</h2>
  <div class="content">
   <p>PARAGRAPH ONE GOES HERE</p>
   <p>PARAGRAPH TWO GOES HERE</p>
  </div>
 </div>
</div>

My external CSS code looks like this: 我的外部CSS代码如下所示:

.overlay {
 position: absolute;
 top: 0;
 bottom: 0;
 left: 0;
 right: 0;
 background: rgba(0,0,0,0.5);
 transition: opacity 200ms;
 visibility: hidden;
 opacity: 0;
 &.light {
  background: rgba(255,255,255,0.5);
 }
 .cancel {
  position: absolute;
  width: 100%;
  height: 100%;
  cursor: default;
 }
 &:target {
  visibility: visible;
  opacity: 1;
 }
}

.popup {
 margin: 75px auto;
 padding: 20px;
 background: #fff;
 border: 1px solid #666;
 width: 300px;
 box-shadow: 0 0 50px rgba(0,0,0,0.5);
 position: relative;
 font-family: "Trebuchet MS", Tahoma, Arial, sans-serif;
 .light & {
  border-color: #aaa;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
 }
 h2 {
  margin-top: 0;
  color: #666;
  font-family: "Trebuchet MS", Tahoma, Arial, sans-serif;
 }
 .close {
  position: absolute;
  width: 20px;
  height: 20px;
  top: 20px;
  right: 20px;
  opacity: 0.8;
  transition: all 200ms;
  font-size: 24px;
  font-weight: bold;
  text-decoration: none;
  color: #666;
  &:hover {
   opacity: 1;
  }
 }
 .content {
  max-height: 400px;
  overflow: auto;
 }
 p {
  margin: 0 0 1em;
  &:last-child {
  margin: 0;
  }
 }
}

you'll have to do something like this, using the html inline style 您将必须使用html内联样式执行类似的操作

<div id="popup1" style="<!-- styles here -->">
   <!-- other code here -->
</div>

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

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