How do I center a <div> vertically?

Possible Duplicate: What's The Best Way of Centering a Div Vertically with CSS This might be a CSS question or it might be a JavaScript question or it might be an HTML question. How do I center a vertically? I have managed to horizontally align a Div object. Here is how I did it. I got the width and the height of the object I wanted to center (XAML CODE) <Grid Background="White

如何将一个<div>垂直居中?

可能重复: 用CSS垂直居中Div的最佳方式是什么? 这可能是一个CSS问题,或者它可能是一个JavaScript问题,或者它可能是一个HTML问题。 我如何垂直居中? 我设法水平对齐Div对象。 这是我如何做到的。 我得到了我想要居中的对象的宽度和高度(XAML CODE) <Grid Background="White" Height="300" Width="738" VerticalAlignment="Center" HorizontalAlignment="Center"> 然后,在托管silverlight控件的html文

How do I center the div vertically?

Possible Duplicate: What's The Best Way of Centering a Div Vertically with CSS .title_text_only{ position:absolute; width:100%; display:none; z-index:9; top:50%; bottom:50%; text-align:center; color:#fff; font-size:18px; text-shadow: 1px 1px 1px #666; } Right now, it doesn't seem to work. top 50% doesn't center it vertically. It's a little to the bottom. It's as if the

如何垂直居中div?

可能重复: 用CSS垂直居中Div的最佳方式是什么? .title_text_only{ position:absolute; width:100%; display:none; z-index:9; top:50%; bottom:50%; text-align:center; color:#fff; font-size:18px; text-shadow: 1px 1px 1px #666; } 现在,它似乎没有工作。 前50%不会垂直居中。 这是一点点底部。 就好像上边界是50%。 如果您可以指定框的高度,则可以使用margin-top: -[height / 2]px (填写[height / 2]并注意

javascript summary my checked input

js__exam_questions(); function js__exam_questions() { $('.js__sum_score_btn').on('click', function(event) { event.preventDefault(); var num = 0; if ($('.js__checked_task input').is(':checked')) { num ++; } else { return false; } $('.js__checked_task'); return $('.js__qustions_result').html( num || 'null'); });

javascript摘要我检查的输入

js__exam_questions(); function js__exam_questions() { $('.js__sum_score_btn').on('click', function(event) { event.preventDefault(); var num = 0; if ($('.js__checked_task input').is(':checked')) { num ++; } else { return false; } $('.js__checked_task'); return $('.js__qustions_result').html( num || 'null'); });

Jquery.height() returns different results using F5 or CTRL+F5

So I am trying to find the height of my images then add a top margin this enables me to impose aa vertical center. I'm running this code, and on an F5 refresh I get correct height but on CTRL+F5 refresh it gives me a much smaller height. I kind of assume this is a loading/delay thing, but I am using document ready so not really sure whats going on. I tried using a php function but it slow

Jquery.height()使用F5或CTRL + F5返回不同的结果

所以我试图找到我的图像的高度,然后添加一个顶部边距,这使我可以施加一个垂直中心。 我运行这个代码,并在F5刷新我得到正确的高度,但在CTRL + F5刷新它给我一个小得多的高度。 我有点认为这是一个加载/延迟的事情,但我正在使用文档准备好,所以不知道发生了什么事情。 我尝试使用PHP函数,但它令人惊讶地减慢了网站,所以必须坚持使用jQuery。 你可以看到它在这里工作。 www.mzillustration.com jQuery(document).re

When a user clicks Show link, display the password, hide it when clicked again

I am trying to get this simple script to work. Basically, when a user clicks on the Show link, it will display the password in the password text box and hide it when it is clicked again. I have searched for solutions but couldn't find anything for what I need. Here is the code: JavaScript function toggle_password(target){ var tag = getElementById(target); var tag2 = getEleme

当用户点击显示链接时,显示密码,再次点击时将其隐藏

我试图让这个简单的脚本工作。 基本上,当用户点击Show链接时,它将在密码文本框中显示密码,并在再次单击时隐藏它。 我已经寻找解决方案,但找不到我需要的任何东西。 代码如下: JavaScript的 function toggle_password(target){ var tag = getElementById(target); var tag2 = getElementById("showhide"); if (tag2.innerHTML == 'Show'){ tag.setAttribute('type', 'text'); tag2.

How to create a mockable class to connect to mongoDB?

I've tried to create a class to connect to a mongoDB (and get a gridFS connection using ( gridfs-stream ). But with that I do get two problems: I do get sometimes the mongo Error server instance in invalid state connected It is impossible for me to mock this class out - using jestJS So I would be very thankful if someone can help me to optimize this class to get a really solid working c

如何创建一个可模拟的类来连接到mongoDB?

我尝试创建一个类来连接到mongoDB(并使用( gridfs-stream )获得一个gridFS连接。但是,我得到两个问题: 我确实有时会server instance in invalid state connected的mongo错误server instance in invalid state connected 我不可能嘲笑这门课 - 用jestJS 所以,如果有人能够帮助我优化这个班级以获得一个非常扎实的工作课程,我将非常感激。 例如,我不喜欢connect()函数中的let that = this 。 示例回购 DB类 c

state returned as function or object literal

I ran into a problem the other day, and asked the great stack community for a solution. The problem: I nested the same module in other modules but I was defining state in this way: state: { // some state here } What was happening is all of my modules despite seeming being nested under disparate modules all shared the same state. The solution state() { return { // state here inste

状态作为函数或对象文字返回

有一天我遇到了问题,并向伟大的堆栈社区寻求解决方案。 问题: 我在其他模块中嵌套了相同的模块,但我是这样定义状态的: state: { // some state here } 发生了什么是我的所有模块,尽管看起来被嵌套在不同的模块中,所有模块都共享相同的状态。 解决方案 state() { return { // state here instead } } 解决方案是有一个函数返回状态,而不是将其定义为对象文字。 为什么有点合理。 这是我的问题 新

jQuery Get Selected Option From Dropdown

Usually I use $("#id").val() to return the value of the selected option, but this time it doesn't work. The selected tag has the id aioConceptName html code <label>Name</label> <input type="text" name="name" /> <select id="aioConceptName"> <option>choose io</option> <option>roma</option> <option>totti</option&g

jQuery从下拉菜单中选择选项

通常我使用$("#id").val()返回所选选项的值,但这次不起作用。 所选标签具有id aioConceptName html代码 <label>Name</label> <input type="text" name="name" /> <select id="aioConceptName"> <option>choose io</option> <option>roma</option> <option>totti</option> </select> 对于下拉选项,你可能需要这样的东西: var c

Prevent Highlight of Text Table

I have a table, and I'm allowing users to 'select' multiple rows. This is all handled using jQuery events and some CSS to visually indicate the row is 'selected'. When the user presses shift, it is possible to select multiple rows. Sometimes this cause text to become highlighted. Is there anyway to prevent this? 有一个CSS3属性。 #yourTable { -webkit-touch-callout: non

防止文本表高亮显示

我有一张桌子,我允许用户'选择'多行。 这一切都使用jQuery事件和一些CSS来处理,以直观地指示该行是“被选中”的。 当用户按下shift键时,可以选择多行。 有时这会导致文字突出显示。 无论如何要防止这一点? 有一个CSS3属性。 #yourTable { -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-selec

How to stop event bubbling on checkbox click

I have a checkbox that I want to perform some Ajax action on the click event, however the checkbox is also inside a container with it's own click behaviour that I don't want to run when the checkbox is clicked. This sample illustrates what I want to do: <html lang="en"> <head> <title>Test</title> <script type="text/javascript" src="http://a

如何停止点击复选框上的事件冒泡

我有一个复选框,我希望对click事件执行一些Ajax操作,但复选框也位于具有自己的单击行为的容器内,当单击该复选框时,该复选框不想运行。 这个例子说明了我想要做的事情: <html lang="en"> <head> <title>Test</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="