如何在CSS中设置文本的背景颜色?(How do I set the background color of targeted text only, using only CSS?)
我想要的是绿色背景不要100%的页面宽度。 我想要它在文本的后面。 HTML:
<!DOCTYPE html> <head> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <h1> The Last Will and Testament of Eric Jones</h1> </body>
style.css中:
h1 { text-align: center; background-color: green; }
Question
How can I dynamically add a green background behind text, not the entire page width, just the text.
Problem
The green is expanding to the entire page with my current code. I am not able to modify the HTML or Javascript, just the CSS file.
HTML
<h1>The Last Will and Testament of Eric Jones</h1>
CSS
h1 { text-align: center; background-color: green; }
原文:https://stackoverflow.com/questions/14310154
最满意答案
您创建的库jar不包含IDE / Gradle可以解析为能够编译/运行测试项目的任何依赖信息。 我看到你正在使用Maven中央仓库,所以你需要做的是将你的库发布到你的本地Maven仓库,并且在测试项目中添加一个依赖信息(不是简单的jar文件)。
因此,在库和测试项目
build.gradle
添加一个Maven本地存储库配置。repositories { mavenLocal() mavenCentral() }
现在您需要将库发布到本地存储库。 当你使用Gradle 3.3时,你可以使用Maven Publishing 。
所以在图书馆
build.gradle
添加一个maven发布信息。publishing { publications { maven(MavenPublication) { groupId 'io.simplepush' artifactId 'project1-sample' version '1.1' from components.java } } }
Gradle“maven-publish”插件可以很容易地发布到本地存储库,自动创建PublishToMavenLocal任务。 所以你可以运行
gradle publishToMavenLocal
它会将你的库与所有的依赖信息一起发布到本地的maven仓库中。
然后你只需要添加一个库信息给你测试项目
build.gradle
dependencies { // other dependencies ..... module 'io.simplepush:project1-sample:1.1' }
I solved it by changing several things.
Thanks to @Babl for pointing me in the right direction.
My new librarybuild.gradle
looks like this:plugins { id 'java' id 'maven-publish' } sourceCompatibility = 1.5 repositories { mavenLocal() mavenCentral() } dependencies { compile 'commons-codec:commons-codec:1.10' compile 'org.apache.httpcomponents:httpcore:4.4.6' compile 'org.apache.httpcomponents:httpclient:4.5.3' } publishing { publications { maven(MavenPublication) { groupId 'io.simplepush' artifactId 'project1-sample' version '1.1' from components.java } } }
Now I can push the library to the local maven repository with
./gradlew publishToMavenLocal
.The
build.gradle
of the test project uses theapplication
plugin and defines a main class (which isHello
in my case). Then I can run./gradlew installDist
to generate an executable file (see Application plugin docs) which puts all dependencies in the classpath and runs just fine.group 'com.test' version '1.0-SNAPSHOT' apply plugin: 'java' apply plugin: 'application' repositories { mavenLocal() mavenCentral() } dependencies { compile 'io.simplepush:project1-sample:1.1' } mainClassName = "Hello"
相关问答
更多-
您创建的库jar不包含IDE / Gradle可以解析为能够编译/运行测试项目的任何依赖信息。 我看到你正在使用Maven中央仓库,所以你需要做的是将你的库发布到你的本地Maven仓库,并且在测试项目中添加一个依赖信息(不是简单的jar文件)。 因此,在库和测试项目build.gradle添加一个Maven本地存储库配置。 repositories { mavenLocal() mavenCentral() } 现在您需要将库发布到本地存储库。 当你使用Gradle 3.3时,你可以使用Mav ...
-
要在没有任何NoClassDefFoundError情况下运行应用程序,您应该在运行时类路径中拥有依赖项。 创建一个胖罐是最简单的解决方案。 改变你的罐子部分如下; jar { manifest { attributes( 'Class-Path': configurations.compile.files.collect {"$it.name"}.join(' '), 'Main-Class': 'products.ProductAPI')} ...
-
如果您想要运行它,则需要创建一个可运行的jar。 您可以使用shadojar插件或扩展jar任务以将运行时deps打包到工件中。 jar { archiveName = 'Name.jar' manifest { attributes 'Main-Class': 'your.main.class', 'Class-Path': configurations.runtime.files.collect { "lib/$it.name" }.jo ...
-
所以问题的根源似乎是gradle如何(或不)处理为com.android.library模块创建android/support/v7/appcompat/R.java 。 通过这里的线索,我可以通过将这个块放在我的build.gradle从命令行和Android中获得工作。 def package_namespace = "com.moxiesoft.netagent.androidchatcustomerclient" def package_namespace_path = package_namesp ...
-
几个小时后 - 问题是,没有生成pom.xml。 使用时创建 uploadArchives { repositories { mavenDeployer { repository(url: mavenLocal().url) } } } 它按预期工作... After few hours - the problem was, that pom.xml was not generated. When created using uploadArchives { ...
-
你在类路径中错过了apache commons-lang。 加 // https://mvnrepository.com/artifact/commons-lang/commons-lang compile group: 'commons-lang', name: 'commons-lang', version: '1.0.1' 到你的gradle文件。 2.6版本有一个包名称 org.apache.commons.lang2 I found the solution to the problem. I ...
-
带外部库的Robolectric NoClassDefFoundError(Robolectric NoClassDefFoundError with external library)[2023-09-29]
基本问题是robolectric不知道你的图书馆资源。 但这可以修复...... 选项1:将 robolectric更新为3.0-rc2 删除自定义运行器。 有一个新类RobolectricGradleTestRunner可以修复库依赖项的资源加载 选项2:使用RobolectricGradleTestRunner的变通方法 删除自定义robolectric runner中的所有代码并添加 public CustomRobolectricRunner(Class> testClass) throws I ... -
org / w3c / dom / ElementTraversal存在于库xml-apis-1.4.01.jar中,htmlunit依赖于它。 因此,作为一种解决方案,您需要将此jar放在项目的类路径中。 但是,htmlunit取决于库的数量。 并且可能会发生这样的情况,在您解决当前错误后,您将获得其他类的noClassDefFoundError。 为了轻松解决它,请开始使用Maven。 创建一个maven项目。 在pom.xml中为htmlunit依赖项添加一个条目,如下所示:
使用StandOut库时出现NoClassDefFoundError(NoClassDefFoundError when using the StandOut Library)[2024-03-20]
请将android studio更新为新版本。 确定您的课程已经映射到您的项目。 尝试将此代码添加到您的应用程序类: protected void attachBaseContext(Context base){ super.attachBaseContext(base); MultiDex.install(this); } 希望它能帮到你。 祝你好运 Please update android studio to new version. Sure tha ...在Gradle构建中启动Gretty时出现NoClassDefFoundError(NoClassDefFoundError when starting Gretty in Gradle build)[2024-01-26]
我遇到了同样的问题。 还没完全解决,但这似乎有所帮助: https://github.com/akhikhl/gretty/issues/5 https://github.com/akhikhl/gretty/issues/72 实质上是说grettyplugin本身的deps必须添加关键字gretty(不是编译也不是运行时) compile group: 'org.apache.poi', name: 'ooxml-schemas', version: '1.3' runtime group: 'org ...相关文章
更多- CSS样式
- SVG文本text
- css常用属性
- 在html使用CSS的方式
- 网络挖掘技术——text mining
- 编写统一、符合习惯的CSS的原则
- css选择器使用
- css盒子模型
- jquery 怎么得到link中text的属性
- Hadoop的I/O
最新问答
更多- h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
- 创建一个功能(Create a function)
- 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
- PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
- Qt冻结循环的原因?(Qt freezing cause of the loop?)
- TableView重复youtube-api结果(TableView Repeating youtube-api result)
- 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
- SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
- 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
- 以编程方式创建UITableView(Creating a UITableView Programmatically)
- 如何打破按钮上的生命周期循环(How to break do-while loop on button)
- C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
- 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
- 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
- Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
- 设置kotlin扩展名(Setting a kotlin extension)
- 如何并排放置两个元件?(How to position two elements side by side?)
- 如何在vim中启用python3?(How to enable python3 in vim?)
- 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
- 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
- Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
- dedecms如何安装?
- 在哪儿学计算机最好?
- 学php哪个的书 最好,本人菜鸟
- 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
- 如何覆盖错误堆栈getter(How to override Error stack getter)
- 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
- USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
- 电脑高中毕业学习去哪里培训
- 正则表达式验证SMTP响应(Regex to validate SMTP Responses)