Joplin实现样式更改

1. 首先,参考了一些教程和优秀网址

Joplin实现字体样式更改
CSS色彩管理
CSS教程

2. 效果展示

效果测试

3. 使用方法:

Joplin的配置路径:
更改配置的路径
userstyle.css内则是可以自己编写的样式表(可以将下面代码拷贝到里面),自行添加的newsprint文件夹则是本次自行放置的字体。

4. 自行更改了一部分颜色,使其在暗主题下能够显示清晰,同时结合了侧边目录。

/*本代码会在我使用过程中不断更新,尽量拷贝使用这个代码到userstyle.css中,且颜色位置我已注释,可自行更改为自己喜欢的颜色*/
/*@time: 2022年6月23日,修改单行注释背景色,使其在暗主题下更明显*/
@font-face {
    font-family: 'PT Serif';
    font-style: normal;
    font-weight: normal;
    src: local('PT Serif'), local('PTSerif-Regular'), url('./newsprint/pt-serif-v9-latin-regular.woff') format('woff');
}
@font-face {
    font-family: 'PT Serif';
    font-style: italic;
    font-weight: normal;
    src: local('PT Serif'), local('PTSerif-Italic'), url('./newsprint/pt-serif-v9-latin-italic.woff') format('woff');
}

@font-face {
    font-family: 'PT Serif';
    font-style: normal;
    font-weight: bold;
    src: local('PT Serif'), local('PTSerif-Bold'), url('./newsprint/pt-serif-v9-latin-700.woff') format('woff');
}

@font-face {
    font-family: 'PT Serif';
    font-style: italic;
    font-weight: bold;
    src: local('PT Serif'), local('PTSerif-BoldItalic'), url('./newsprint/pt-serif-v9-latin-700italic.woff') format('woff');
}


html {
    font-size: 16px;
    color: #1f0909;
}

body {  
    font-family: "PT Serif", 'Times New Roman', Times, serif;
    /*-webkit-font-smoothing: antialiased;*/
    line-height: 1.6rem;
    /*font-size: 0.5rem*/
    letter-spacing: 0;
    margin: 0;
    overflow-x: hidden;
    color: #F4F5F0;  /*body,文本颜色*/
}

p{
    font-size: 1.0rem
}
ol,ul{  /*ol:有序列表, ol:无序列表 */
    font-size: 1.0rem
}

body > *:first-child {
    margin-top: 0 !important;
}

body > *:last-child {
    margin-bottom: 0 !important;
}


a {   /*a :链接属性*/
    color: #FF6900;
    font-weight: 600;
    padding: 0 2px;
    text-decoration: none;
}

h1,
h2,
h3,
h4,
h5,
h6 {   /*标题*/
    position: relative;
    margin-top: 1rem;
    margin-bottom: 1rem;
    font-weight: bold;
    line-height: 1.4;
    cursor: text;
	color: #72D1DF;  /*标题颜色。蓝绿色*/
}

h1 tt,
h1 code {
    font-size: inherit !important;
}

h2 tt,
h2 code {
    font-size: inherit !important;
}

h3 tt,
h3 code {
    font-size: inherit !important;
}

h4 tt,
h4 code {
    font-size: inherit !important;
}

h5 tt,
h5 code {
    font-size: inherit !important;
}

h6 tt,
h6 code {
    font-size: inherit !important;
}

/*下面是标题链接的颜色*/
h1 a,
h2 a,
h3 a,
h4 a,
h5 a,
h6 a{
    /*color: #42b983;*/
    color: #9AFF1C;
}

h1 {
    padding-bottom: .4rem;
    font-size: 1.8rem;
    line-height: 1.3;
    font-style: normal;
    border-bottom: none;
}

h2 {
    font-size: 1.6rem;
    line-height: 1.225;
    margin: 35px 0 15px;
    padding-bottom: 0.5em;
    border-bottom: 1px solid #ddd;
    font-style: normal;
}

h3 {
    font-size: 1.4rem;
    /*line-height: 1.43;*/
    margin: 20px 0 7px;
    font-style: normal;
}

h4 {
    font-size: 1.3rem;
    font-style: normal;
}

h5 {
    font-size: 1.2rem;
    font-style: normal;
}

h6 {
    font-size: 1.1rem;
    /*color: #777;*/
    font-style: normal;
}

p,
blockquote,
ul,
ol,
dl,
table {  /*table:表格*/
    margin: 0.8em 0;
}

li > ol,
li > ul {
    margin: 0 0;
}

p pre {
    border: none;
}

hr {
    height: 2px;
    padding: 0;
    margin: 16px 0;
    /* background-color: #e7e7e7; */
    border: 0 none;
    overflow: hidden;
    box-sizing: content-box;
}

body > h2:first-child {
    margin-top: 0;
    padding-top: 0;
}

body > h1:first-child {
    margin-top: 0;
    padding-top: 0;
}

body > h1:first-child + h2 {
    margin-top: 0;
    padding-top: 0;
}

body > h3:first-child,
body > h4:first-child,
body > h5:first-child,
body > h6:first-child {
    margin-top: 0;
    padding-top: 0;
}

a:first-child h1,
a:first-child h2,
a:first-child h3,
a:first-child h4,
a:first-child h5,
a:first-child h6 {
    margin-top: 0;
    padding-top: 0;
}

h1 p,
h2 p,
h3 p,
h4 p,
h5 p,
h6 p {
    margin-top: 0;
}

li p.first {
    display: inline-block;
}

ul,
ol {
    padding-left: 30px;
}

ul:first-child,
ol:first-child {
    margin-top: 0;
}

ul:last-child,
ol:last-child {
    margin-bottom: 0;
}

blockquote {
    border-left: 4px solid #42b983;
    /*padding: 10px 10px;*/
    color: #2B3F52;
    background-color: #0033A0;  /*块引用*/
    border-left-color: #ECF0F3;
}

p code{
    border: none !important;
    color: #ff6666;
    background-color: #0033A0 !important;  /*单行,代码块背景色*/
    /*border: none;*/
}

strong {

    color:#FF9933;    /*加粗字体颜色*/

    size: 100px;

    margin: 0em;

    font-size: inherit;

    /*font-style: italic;*/

}

@media print {
    html {
        font-size: 13px;
    }

    table,
    pre {
        page-break-inside: avoid;
    }

    pre {
        word-wrap: break-word;
    }
    h1,h2,h3,h4,h5,h6 {
    	color: #336699;
    	page-break-inside: avoid;
    	page-break-after: avoid;
    }
    img { 
     page-break-inside:avoid;
     page-break-after:avoid;
 	}
 	table,pre { page-break-inside:avoid}
    ul,ol,dl{ page-break-before:avoid}
    a{page-break-inside:avoid}
    blockquote {page-break-inside: avoid;}
}

/* 侧边栏效果 */
nav.table-of-contents>ul {
    top: 0;
    right: 0;
    position: fixed;
    z-index: var(--z-toc);
    background: var(--dark-grey);
    padding: var(--base-size-8);
    border-radius: var(--base-size-4);
    max-width: 30%;
    font-size: var(--base-size-10);
    max-height: var(--base-size-272);
    overflow: scroll;
    opacity: 0.6;
}

nav.table-of-contents ul {
    list-style-type: none;
    margin-left: var(--base-size-4);
}

nav.table-of-contents li {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0;
}

nav.table-of-contents li a {
    padding: 0;

}

@media all and (min-width: 920px) {
    nav.table-of-contents>ul {
        height: 100%;
        max-height: 100%;
    }

    #rendered-md {
        width: 75%;
    }
}


5. 打包地址:

可以自行下载放入上面所述的joplin路径文件入口:
(yunpan链接:https://pan.baidu.com/s/1kWxH3k0YinPrLvZEB3bshA?pwd=3tg9
提取码:3tg9
–来自百度网盘超级会员V8的分享)
(
cadn:https://download.csdn.net/download/qq_20467929/85748956
)

  • 6
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
好的,以下是一个简单的安卓应用程序,其中包括一个菜单按钮和相关的菜单和子菜单,以及点击子菜单项会弹出提示信息的功能。 首先,在XML布局文件中添加一个按钮,如下所示: ``` <Button android:id="@+id/menu_button" android:text="菜单" android:layout_width="wrap_content" android:layout_height="wrap_content" /> ``` 接下来,在Java代码中为按钮添加一个点击事件监听器,当用户点击按钮时,会创建并显示菜单和子菜单,如下所示: ``` Button menuButton = findViewById(R.id.menu_button); menuButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PopupMenu menu = new PopupMenu(MainActivity.this, v); menu.getMenuInflater().inflate(R.menu.main_menu, menu.getMenu()); menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.menu_male_singer: showSubMenu(R.menu.male_singer_menu); return true; case R.id.menu_female_singer: showSubMenu(R.menu.female_singer_menu); return true; case R.id.menu_group: showSubMenu(R.menu.group_menu); return true; } return false; } }); menu.show(); } }); ``` 在上面的代码中,我们使用`PopupMenu`类创建了一个菜单,并使用`getMenuInflater()`方法从菜单资源文件中加载菜单项。当用户选择其中一个选项时,会调用`showSubMenu()`方法显示对应的子菜单。 接下来,我们定义`showSubMenu()`方法来显示子菜单并添加点击事件监听器,如下所示: ``` private void showSubMenu(int menuResId) { PopupMenu subMenu = new PopupMenu(MainActivity.this, findViewById(R.id.menu_button)); subMenu.getMenuInflater().inflate(menuResId, subMenu.getMenu()); subMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.submenu_tfboys: showMessage("你选择的组合是TFBOYS"); return true; case R.id.submenu_jolin: showMessage("你选择的女歌手是蔡依林"); return true; case R.id.submenu_jay: showMessage("你选择的男歌手是周杰伦"); return true; } return false; } }); subMenu.show(); } ``` 在上面的代码中,我们使用`PopupMenu`类创建了一个子菜单,并使用`getMenuInflater()`方法从子菜单资源文件中加载菜单项。当用户选择其中一个选项时,会调用`showMessage()`方法显示对应的提示信息。 最后,我们定义`showMessage()`方法来显示提示信息,如下所示: ``` private void showMessage(String message) { Toast.makeText(MainActivity.this, message, Toast.LENGTH_SHORT).show(); } ``` 在上面的代码中,我们使用`Toast`类创建一个短时间的提示信息,并将其显示在屏幕上。 完整的代码实现如下所示,可以将其添加到`MainActivity.java`文件中: ``` import android.os.Bundle; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.PopupMenu; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button menuButton = findViewById(R.id.menu_button); menuButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PopupMenu menu = new PopupMenu(MainActivity.this, v); menu.getMenuInflater().inflate(R.menu.main_menu, menu.getMenu()); menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.menu_male_singer: showSubMenu(R.menu.male_singer_menu); return true; case R.id.menu_female_singer: showSubMenu(R.menu.female_singer_menu); return true; case R.id.menu_group: showSubMenu(R.menu.group_menu); return true; } return false; } }); menu.show(); } }); } private void showSubMenu(int menuResId) { PopupMenu subMenu = new PopupMenu(MainActivity.this, findViewById(R.id.menu_button)); subMenu.getMenuInflater().inflate(menuResId, subMenu.getMenu()); subMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.submenu_tfboys: showMessage("你选择的组合是TFBOYS"); return true; case R.id.submenu_jolin: showMessage("你选择的女歌手是蔡依林"); return true; case R.id.submenu_jay: showMessage("你选择的男歌手是周杰伦"); return true; } return false; } }); subMenu.show(); } private void showMessage(String message) { Toast.makeText(MainActivity.this, message, Toast.LENGTH_SHORT).show(); } } ``` 希望这可以帮助你实现你想要的功能!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值