2013-10-09 28 views
0

这里是我的html代码,其中的内容没有出现在我的div中。 Tetxtarea,复选框可以看到,但我写的文字无法看到。div内容中的文本无法正常显示

另外我写的CSS应该使屏幕中间的div也不在屏幕中心。

<!DOCTYPE html> 
<html> 
<head> 
<meta charset="utf-8"> 
<title>Creating Popup Div | istockphp.com</title> 
<link href="style.css" rel="stylesheet" type="text/css" media="all" /> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"> </script> 
<script type="text/javascript" src="script.js"></script> 

<style type="text/css"> 
.center{ 
    position: absolute; 
    height: 50px; 
    width: 50px; 
    background:red; 
    top:calc(50% - 50px/2); 
    left:calc(50% - 50px/2); 
} 
</style> 
</head> 
<body> 
    <a href="#" class="topopup">Click Here Trigger</a> 


    <div id="toPopup" class="center" style="background-color: #EDEFF1; height:300px;width:500px; -moz-border-radius-bottomright: 15px; border-bottom-right-radius: 15px; -moz-border-radius-bottomleft: 15px; moz-border-radius-topleft: 15px;moz-border-radius-topright: 15px; border-bottom-left-radius: 15px; "> 

     <div class="close"></div> 
     <span class="ecs_tooltip">Press Esc to close <span class="arrow"></span></span> 
     <div id="popup_content"> <!--your content start--> 
     <p><b>Share post </b></p> 
      <textarea style="height:65px;width:400px;"> 
      </textarea> <br>   
      <input type="checkbox"> - Facebook <hr> </input> 
      <input type="checkbox"> - Twitter <hr> 
      <input type="checkbox"> - Linked in <hr> 
      </br></br>     
     </div> <!--your content end-->  
    </div> 
</art> 
</body> 
</html> 

的jsfiddle链接:

http://jsfiddle.net/UD3U7/

上的jsfiddle它显示的文本。其实div应该弹出而直接出现。 它可以在jsfiddle上看到。

但我的本地主机文本中的div无法看到。

+2

提供有关问题的的jsfiddle代码,而不是完整的HTML代码。 – Nitesh

回答

2

检查与此。对于textarea,开放和关闭标签(即使是空格)之间的内容将被视为内容。

<!DOCTYPE html> 
<html> 
<head> 
<meta charset="utf-8"> 
<title>Creating Popup Div | istockphp.com</title> 
<link href="style.css" rel="stylesheet" type="text/css" media="all" /> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"> </script> 
<script type="text/javascript" src="script.js"></script> 

<style type="text/css"> 
.center{ 
    position: absolute; 
    height: 50px; 
    width: 50px; 
    background:red; 
    margin: auto; 
    bottom: 0; 
    left: 0; 
    top: 0; 
    right: 0; 
} 
</style> 
</head> 
<body> 
    <a href="#" class="topopup">Click Here Trigger</a> 


    <div id="toPopup" class="center" style="background-color: #EDEFF1; height:300px;width:500px; -moz-border-radius-bottomright: 15px; border-bottom-right-radius: 15px; -moz-border-radius-bottomleft: 15px; moz-border-radius-topleft: 15px;moz-border-radius-topright: 15px; border-bottom-left-radius: 15px; "> 

     <div class="close"></div> 
     <span class="ecs_tooltip">Press Esc to close <span class="arrow"></span></span> 
     <div id="popup_content"> <!--your content start--> 
     <p><b>Share post </b></p> 
      <textarea style="height:65px;width:400px;"></textarea> <br>   
      <input type="checkbox"> - Facebook <hr> 
      <input type="checkbox"> - Twitter <hr> 
      <input type="checkbox"> - Linked in <hr> 
      </br></br>     
     </div> <!--your content end-->  
    </div> 
</body> 
</html> 
+0

没有改进。位置已更改,但尚未位于中央。而且文字也不可见。 –

+0

现在检查小提琴并告诉需要完成的更改。 –

1

我不知道你的意思“无论文字我已经写不能被视为”但我已经修复你的CSS和HTML允许弹出DIV在网页居中什么。

如果你有一个CSS文件,然后把所有的样式放在CSS文件中。不要在HTML和CSS中混合使用样式,因为在调试和维护代码时会遇到问题。

下面是更新小提琴:http://jsfiddle.net/JJ5rx/

HTML:

<a href="#" class="topopup">Click Here Trigger</a> 

<div id="toPopup" class="center"> 
    <div class="close"></div> 
    <span class="ecs_tooltip">Press Esc to close <span class="arrow"></span></span> 
    <div id="popup_content"> <!--your content start--> 
     <p><b>Share post </b></p> 
      <textarea cols="50" rows="5" placeholder="Enter comment..."></textarea> <br> 

      <input type="checkbox"> - Facebook <hr> </input> 
      <input type="checkbox"> - Twitter <hr> 
      <input type="checkbox"> - Linked in <hr> 
      </br></br> 

    </div> <!--your content end--> 

</div> 

CSS:

.center{ 
    margin: 0 auto; 
    background-color: #EDEFF1; 
    height:300px; 
    width:450px; 
    -moz-border-radius-bottomright: 15px; 
    border-bottom-right-radius: 15px; 
    -moz-border-radius-bottomleft: 15px; 
    moz-border-radius-topleft: 15px; 
    moz-border-radius-topright: 15px; 
    border-bottom-left-radius: 15px; 
} 
1

不明白为什么你不能看到你写在textarea的文本,我能够。 我建议你改变的东西喜欢的风格:

.center{ 
     position: absolute; 
     height:300px; 
     width:500px; 
     margin: -150px 0 0 -250px; 
     top: 50%; 
     left: 50%; 
     background-color: #EDEFF1; 
     border-bottom-right-radius: 15px; 
     border-bottom-left-radius: 15px; 
     border-top-right-radius: 15px; 
     border-top-left-radius: 15px; 
     -moz-border-radius-bottomright: 15px; 
     -moz-border-radius-bottomleft: 15px; 
     -moz-border-radius-topleft: 15px; 
     -moz-border-radius-topright: 15px; 
    } 

这应该解决的中心问题,因为你有一类与风格的描述,我建议把所有的样式选项在那里,我意味着

<div id="toPopup" class="center" style="background-color: #EDEFF1; height:300px;width:500px; -moz-border-radius-bottomright: 15px; border-bottom-right-radius: 15px; -moz-border-radius-bottomleft: 15px; moz-border-radius-topleft: 15px;moz-border-radius-topright: 15px; border-bottom-left-radius: 15px; "> 

应该成为只是

<div id="toPopup" class="center" >