2016-11-03 52 views
-3

我陷入了将HTML源文本作为CSS编辑的简单任务。我希望有人能够帮助我确信有一个非常简单的答案。我遇到困难的原因是因为当我尝试查看我试图编辑的网页的.css文件时,所有文本元素(如文本标题等)似乎都从代码中省略。我对CSS一无所知,所以我很挣扎。Stuck编辑HTML文本源代码为CSS

下面是HTML源:

<div> 
 
    <label class='text-contrast'>Check-in</label> 
 
    <input autocomplete='off' required type='text' id='cf-query-start_date' class=' date form-control' value='' data-alt='#alt_cf-query-start_date' data-datepicker='' /> 
 
    <input type='hidden' name='start_date' id='alt_cf-query-start_date' class='alt_date' value='2016-11-04'> 
 
</div> 
 
<div class='input-placeholder-group form-group mobile-browser mobidates end_date '> 
 
    <label class='text-contrast'>Check-out</label> 
 
</div>

很简单,我想改变“入住”到“日期范围”并删除“退房”文本元素。需要使用CSS编辑器来完成。

编辑:缺少DIV部分:

<div class="container"> 
     <h2 class="text-jumbo text-contrast">REDACTED</h2> 
        <div class="sticker"> 
      <form method='get' action='/reserve' id='cf-query' class='search-area full form-inline' role='form'>  
     <input type='hidden' name='filter_item_id' id='filter_item_id' value='' /> 
     <input type='hidden' name='customer_id' value=''/> 
     <input type='hidden' name='date' id='date' value='' /> 
     <input type='hidden' id='widget-arg-item_id' class='cf-widget-arg' name='item_id' value='' /><input type='hidden' name='category_id' id='category_id' value='0'/><input type='hidden' name='view' id='cf-query-view' value='H'/> 
     <div class='search-form-input-wrapper'> 
     <div class='input-placeholder-group form-group mobile-browser mobidates start_date '> 
+2

不知道我理解你想要做什么 - 编辑“HTML源为CSS”听起来不像一个简单的任务或似乎太大的意义。你能再详细一点吗?什么阻止你编辑你粘贴的HTML源代码? –

+0

发布缺少的开始'div',所以我们会看到可以做什么。 – LGSon

+0

听起来就像你想用CSS改变HTML源代码,你基本上不能这样做。有些内容像[内容属性](https://developer.mozilla.org/en-US/docs/Web/CSS/content),但没有什么会做你所问的(据我所知) 。 – hungerstar

回答

-2

我认为这是更好的显示和隐藏,而不是删除正如你看到的,我添加的类SHW,HDN

<label class='text-contrast Shw'>Check-in</label> 
<label class='text-contrast Hdn'>Date Range</label> 
      <input autocomplete='off' required type='text' id='cf-query-start_date' class=' date form-control' value='' data-alt='#alt_cf-query-start_date' data-datepicker=''/> 
       <input type='hidden' name='start_date' id='alt_cf-query-start_date' class='alt_date' value='2016-11-04'> 
     </div> 
     <div class='input-placeholder-group form-group mobile-browser mobidates end_date '> 
      <label class='text-contrast'>Check-out</label> 
+0

如果OP可以将类添加到标记中,为什么他们不直接更新标记呢? – hungerstar

+0

我们可以使用javascript或jquery更改HTMl,但我不认为使用CSS来编辑HTML内容 –

+0

JS未被标记为在帖子中,因此它可能不是OP的可行选项。 – hungerstar

0

,如果你能只能编辑CSS级别的内容,并且不能编辑HTML文件,那么唯一合理的方法是:

.text-contrast { 
    display: none; 
} 
.text-contrast:after { 
    content: 'Date range'; 
} 

但请记住它将应用于所有text-contrast元素,因此如果您在代码中包含更多这些元素,那么您可能很需要以某种方式更改HTML。

+0

签入和签出共享相同的CSS选择器,因此您的伪装元素不会出现。你需要更多的特定选择器来防止这种情况。 – hungerstar

1

假设缺少启动 div看起来像这样 <div class='input-placeholder-group form-group mobile-browser mobidates start_date '>你可以做

div.start_date label,  /* this rule take out the Check-in/out labels */ 
 
div.end_date label { 
 
    display: none; 
 
} 
 
div.start_date::before { /* this rule add the Date Range */ 
 
    content: 'Date Range' 
 
}
<div class="container"> 
 
    <h2 class="text-jumbo text-contrast">REDACTED</h2> 
 
    <div class="sticker"> 
 
    <form method='get' action='/reserve' id='cf-query' class='search-area full form-inline' role='form'> 
 
     <input type='hidden' name='filter_item_id' id='filter_item_id' value='' /> 
 
     <input type='hidden' name='customer_id' value='' /> 
 
     <input type='hidden' name='date' id='date' value='' /> 
 
     <input type='hidden' id='widget-arg-item_id' class='cf-widget-arg' name='item_id' value='' /> 
 
     <input type='hidden' name='category_id' id='category_id' value='0' /> 
 
     <input type='hidden' name='view' id='cf-query-view' value='H' /> 
 
     <div class='search-form-input-wrapper'> 
 
     <div class='input-placeholder-group form-group mobile-browser mobidates start_date '> 
 
      <label class='text-contrast'>Check-in</label> 
 
      <input autocomplete='off' required type='text' id='cf-query-start_date' class=' date form-control' value='' data-alt='#alt_cf-query-start_date' data-datepicker='' /> 
 
      <input type='hidden' name='start_date' id='alt_cf-query-start_date' class='alt_date' value='2016-11-04'> 
 
     </div> 
 
     <div class='input-placeholder-group form-group mobile-browser mobidates end_date '> 
 
      <label class='text-contrast'>Check-out</label> 
 
     </div> 
 
     </div> 
 
    </form> 
 
    </div> 
 
</div>

+0

这将'日期范围'放在'入住'之前(不会替换)。它也不隐藏'退房'。尽管谢谢你的回应! – winterfrost

+0

@winterfrost当然它的工作,看看你的最后一个div在你发布的缺失html – LGSon

+0

@winterfrost更新我的答案与你添加到你的问题的代码 – LGSon

1

隐藏退房文字很简单:

.end_date .text-contrast { 
    display: none; 
} 

我们”重新错过了div那个ds是第一个.text-contrast元素,但可以根据第二个div.end_date的方式假设它具有类别.start_date(或类似)。因此,这应该改变画面上显示的文字工作:

.start_date .text-contrast { 
    display: block; 
    position: relative; 
    text-indent: -9999px; 
} 
.start_date .text-contrast::before { 
    content: 'Date range'; 
    position: absolute; 
    text-indent: 0; 
} 
+0

我用这个来隐藏'Check-out',但是其余的建议都没有奏效。 'code'.end_date的.text对比度{ 位置:相对; 文本缩进:-9999px; }。 – winterfrost

+0

糟糕'.start_date的.text-contrast'也需要'显示:块;'或'显示:直列block'(根据页面布局的方式)'text-indent'属性可以工作 –

+0

不确定我了解你,这个地方'*日期范围'*位于*'签入'之上。 start_date .t外部对比显示:块{ 位置:相对; text-indent:-9999px; } .start_date .text-contrast :: before { content:'Date range'; position:absolute; text-indent:0; }' – winterfrost