CSS:获取表单标签以显示在表单元素之上(jsfiddle)(CSS: Get form label to display on top of form element (jsfiddle))
我试图让表单标签显示在每个表单元素的顶部。 我有jsfiddle这样做。
问题是,如何在每行保留其标签的同时获得多个表单元素?
你可以在我的例子中看到我在同一行上有“city,state,zip”,但由于我的CSS中的
display: block
,它将它们分成不同的行。label { font-weight:bold; display: block; } <form> <label for="name">Name</label> <input type="text" name="name" /><br /> <label for="email">Email</label> <input type="text" name="email" /><br /> <label for="city">City</label> <input type="text" name="city" /> <label for="state">State</label> <input type="text" name="state" /> <label for="zip">Zip</label> <input type="text" name="zip" /><br /> <label for="last">Last</label> <input type="text" name="last" /> </form>
I am trying to get the form label to display on top of each form element. I have the jsfiddle where this is done.
The problem is, how do I get more than one form element per line while keeping its label directly above it?
You can see in my example how I have "city, state, zip" all on the same line, but because of
display: block
in my CSS, it is breaking them up onto separate lines.label { font-weight:bold; display: block; } <form> <label for="name">Name</label> <input type="text" name="name" /><br /> <label for="email">Email</label> <input type="text" name="email" /><br /> <label for="city">City</label> <input type="text" name="city" /> <label for="state">State</label> <input type="text" name="state" /> <label for="zip">Zip</label> <input type="text" name="zip" /><br /> <label for="last">Last</label> <input type="text" name="last" /> </form>
原文:https://stackoverflow.com/questions/13330678
最满意答案
我刚从你的代码中注意到这一行:
command.ExecuteNonQuery();
只被召唤一次。 当你这样做时会发生什么:
var connection = new SQLiteConnection("DataSource=:memory:;Version=3;New=True;"); connection.Open(); string sql = "CREATE TABLE recently_viewed(movieid INTEGER,picture TEXT)"; SQLiteCommand command = new SQLiteCommand(sql, connection); command.ExecuteNonQuery(); using ( command = connection.CreateCommand()) { command.CommandText = "INSERT into recently_viewed(movieid ,picture) values(@movieid,@picture)"; command.Prepare(); command.Parameters.AddWithValue("@movieid", id); command.Parameters.AddWithValue("@picture", picture); command.ExecuteNonQuery(); } string count_table = " SELECT count(*) FROM recently_viewed"; SQLiteCommand com3 = new SQLiteCommand(count_table, connection); com3.ExecuteNonQuery(); int ctable = Convert.ToInt32(com3.ExecuteScalar().ToString()); Response.Write(ctable); connection.Close();
I just noticed from your code that this line:
command.ExecuteNonQuery();
is called only once. What happens when you do:
var connection = new SQLiteConnection("DataSource=:memory:;Version=3;New=True;"); connection.Open(); string sql = "CREATE TABLE recently_viewed(movieid INTEGER,picture TEXT)"; SQLiteCommand command = new SQLiteCommand(sql, connection); command.ExecuteNonQuery(); using ( command = connection.CreateCommand()) { command.CommandText = "INSERT into recently_viewed(movieid ,picture) values(@movieid,@picture)"; command.Prepare(); command.Parameters.AddWithValue("@movieid", id); command.Parameters.AddWithValue("@picture", picture); command.ExecuteNonQuery(); } string count_table = " SELECT count(*) FROM recently_viewed"; SQLiteCommand com3 = new SQLiteCommand(count_table, connection); com3.ExecuteNonQuery(); int ctable = Convert.ToInt32(com3.ExecuteScalar().ToString()); Response.Write(ctable); connection.Close();
相关问答
更多-
该错误消息映射到SQLITE_MISUSE(源代码可在http://www.sqlite.org上获得 )。 有关使用来自多个线程的sqlite3 *数据库句柄的限制,请参阅http://www.sqlite.org/faq.html#q6 。 实际上,您可以跨线程重用数据库句柄和语句,但一个线程在其他线程启动之前必须完全访问数据库(即重叠访问不安全)。 这听起来像是你正在发生的事情,并与SQLITE_MISUSE错误代码一致。 更多请看下面的SO帖子.. 如何在iPhone上从后台线程正确调用SQLite ...
-
最后我的解决方案是Inversion Of Control:我改变了我的数据层,所以我可以注入一个自定义的SessionFactoryBuilder类,它使得Fluently.Configure(...)魔术。 在我的数据层中,我使用“真正的”MySqlSessionFactoryBuilder,在我的测试项目中,我编写TestMySqlFactoryBuilder或TestSQLiteSessionFactoryBuilder类,或者我需要的任何东西。 我仍然遇到SQLite功能问题,需要为所有会话使用相 ...
-
显然系统无法找到sqlite3。 我必须提供安装路径。 以下是最后的片段 namespace :mockdb do sqlite_path = "/usr/bin/sqlite3" sql_file = "db/#{Rails.env}.sqlite3" desc "Back up the database" task :backup => :environment do puts "Backing up the database.." system "#{sqlite_pa ...
-
URI文件名仅适用于sqlite3_open_v2 。 URI filenames work only with sqlite3_open_v2.
-
我刚从你的代码中注意到这一行: command.ExecuteNonQuery(); 只被召唤一次。 当你这样做时会发生什么: var connection = new SQLiteConnection("DataSource=:memory:;Version=3;New=True;"); connection.Open(); string sql = "CREATE TABLE recently_viewed(movieid INTEGER,picture TEXT)"; SQLiteComma ...
-
至于我在你看到的setUp() ,TestCase会覆盖\PHPUnit\DbUnit\TestCaseTrait的setUp() ,其中包含负责设置和拆除的逻辑。 如果你需要在TestCase中有不同的setUp ,那么最好按照文档中的描述创建自己的基类,并从中扩展你的TestCase,并从子TestCase调用parent::setUp() 更新: 必须在运行测试套件之前创建数据库,表,序列,触发器和视图。 它取自这里 ,并有更多有用的提示。 基本上这意味着在运行测试之前,所有表,列,索引,约束以及与测 ...
-
您可以使用联机备份API将内存数据库传输到在共享内存中创建的基于文件的数据库(对于Linux,例如在/ dev / shm中),从而避免磁盘操作。 然后将此伪文件传输到远程主机(仍然放在/ dev / shm中),并使用在线加载API从基于文件的数据库传输到目标内存数据库。 看到: http://www.sqlite.org/backup.html http://www.sqlite.org/c3ref/backup_finish.html AFAIK,没有API可以在没有中间数据库的情况下执行在线/加载。 ...
-
sqlite永久在内存中(sqlite permanently in-memory)[2022-08-19]
有多种方法可以做到: 什么都不做,让操作系统将数据库缓存在磁盘缓存/内存缓冲区中。 如果你有一个小型数据库(<50 MB很小),并且你有大量内存,这是很好的。 使用tmpfs并将数据库文件复制到其中,然后在PHP中打开它。 使用sqlite://:memory:但您将从空白数据库开始)。 There are multiple ways to do it: Do nothing, and let the OS cache the database in disk caches / memory buffers ... -
基于内存数据库的SQLite 文档 ,我将尝试使用URI文件名约定file::memory:?cache=shared等命名的数据源,而不是:memory:并特别注意所有连接所在的缓存名称)告诉使用)。 正如页面上所解释的那样,a :memory:每个实例都是彼此不同的,就像你找到的那样。 请注意,在与内存数据库建立连接之前,您可能还必须首先启用共享缓存模式(在共享缓存文档中指定,并调用sqlite3_enable_shared_cache(int)以使其工作。 Based on the SQLite do ...
-
它取决于您的数据结构所需的服务。 你只需要从地图中检索值? 或者你需要做一个复杂的查询或排序? 对于数据库内部结构来说,没有什么神奇的地方,为了使它简单的数据结构更快。 在数据库中有更多的工具可以处理大量的数据,这些数据可能会占用CPU和内存。 如果你只需要一个像功能词典一样的地方,那么考虑一个更复杂的数据库 its depends on the services you require from your data structure. do you only need to retrieve value ...